class Novika::Dict

Overview

Default dictionary protocol implementation: default block dictionary implementation. Uses a hash map for storage.

Note: setting or getting with blocks as keys performs a linear scan for now. The semantics for this is unstable.

Included Modules

Defined in:

novika/dict.cr

Instance Method Summary

Instance methods inherited from module Novika::IDict

clear clear, copy : IDict copy, count : Int32 count, del(name : Form) del, each(& : Form, Form -> ) each, empty? : Bool empty?, get(name : Form, & : Form -> Entry | Nil) : Entry | Nil get, has?(name : Form) : Bool has?, import!(donor : IDict) import!, set(name : Form, entry : Entry) : Entry set, to_dict : Dict to_dict

Instance Method Detail

def ==(other : Dict) #

def clear #
Description copied from module Novika::IDict

Removes all entries in this dictionary.


def copy : IDict #
Description copied from module Novika::IDict

Returns a shallow copy of this dictionary.


def count : Int32 #
Description copied from module Novika::IDict

Returns the amount of entries in this dictionary.


def del(name : Form) #
Description copied from module Novika::IDict

Deletes the entry corresponding to name form in this dictionary if it exists. Otherwise, does nothing.


def each(&) #
Description copied from module Novika::IDict

Yields key, value forms in this dictionary.


def get(name : Form, &) : Entry | Nil #
Description copied from module Novika::IDict

Returns the entry corresponding to name form in this dictionary, or yields with name and returns the block result.


def has?(name : Form) : Bool #
Description copied from module Novika::IDict

Returns whether this dictionary has an entry corresponding to name form.


def import!(donor : IDict) #
Description copied from module Novika::IDict

Imports entries from donor dictionary into this dictionary.

Entries whose names are preceded by one or more _ are not imported (they are considered private).


def set(name : Form, entry : Entry) : Entry #
Description copied from module Novika::IDict

Assigns name form to entry in this dictionary.


def to_dict : Dict #
Description copied from module Novika::IDict

Converts this dictionary to the standard Dict implementation (used in e.g. serialization).