container.map - Palamecia/mint GitHub Wiki

Module

load container.map

This module provides the Container.Map class which store objects and provides fast lookup of the value associated with a key.

Packages

Classes

Container.Map

This class create a dictionary based on Container.RedBlackTree which stores a liste of values mapped to a key value.

When iterating over a Container.Map, the elements are always sorted by key. A comparator function must be provided to the class instances to be used to sort keys. The values used as key in the instances must provide the operator used by the function.

Members

Modifiers Member Description
+ const != Returns true if other is not equal to this dictionary; otherwise returns ...
+ const + Returns a dictionary which is the result of concatenating self and value....
+ const == Returns true if other is equal to this dictionary; otherwise returns fa...
- class Node Internal node structure.
+ const (#ContainerMap-4) Returns the value associated to the specified key in the dictionary. If k...
+ const []= Replaces the value of the element associated to the specified key in the di...
+ const clear Removes all the elements of the dictionary.
+ const contains Returns true if the dictionary contains the key key element; otherwise re...
+ const count Returns the number of occurrences of the value value in the dictionary.
+ const data Returns an hash containing each elements of the dictionary.
+ const each Apply the func function to each elements of the dictionary. If func can t...
+ const get Returns the value associated to the specified key in the dictionary. If k...
+ const in Returns an iterator on each element of the dictionary. The elements are pro...
+ const insert Inserts value in the dictionary associated with the specified key. If k...
+ const isEmpty Returns true if the dictionary is empty; otherwise returns false.
+ const items Returns an array containing each elements of the dictionary. The elements a...
+ const keys Returns an array containing each keys of the dictionary.
+ const new Creates a new instance of Container.Map. If values is given, the dictionary...
+ const remove Removes the element associated to the specified key in the dictionary. If ...
- final root Root element node.
+ const set Replaces the value of the element associated to the specified key in the di...
+ const size Returns the number of elements in the dictionary.
+ const toArray Converts the dictionary to an array. Same as keys.
+ const toHash Converts the dictionary to an hash. Same as data.
+ const values Returns an array containing each values of the dictionary.

Container.Map.Node

Internal node structure.

Members

Modifiers Member Description
+ class Comparator Internal node comparison strategy.
+ final key Node key value.
+ const new Creates a new node with the givens key and value .
+ final value Node mapped value.

Container.Map.Node.Comparator

Internal node comparison strategy.

Members

Modifiers Member Description
+ const () Returns true if left is before right; otherwise returns false .
- final comparator Comparison function.
+ const getComparator Returns the comparison function used by the strategy.
+ const new Creates a new comparator using the given comparator function.

Descriptions

Container.Map.!=

def (const self, const other)

Returns true if other is not equal to this dictionary; otherwise returns false.

Two dictionaries are considered equal if they contain the same keys associated to the same value.

This function requires the values to have an implementation of the != operator. The keys are compared using the comparator function.

Container.Map.+

def (self, value)

Returns a dictionary which is the result of concatenating self and value. The created dictionary use the comparator function of self. If a key is contained in both self and value, the element of self is used.

Container.Map.==

def (const self, const other)

Returns true if other is equal to this dictionary; otherwise returns false.

Two dictionaries are considered equal if they contain the same keys associated to the same value.

This function requires the values to have an implementation of the != operator. The keys are compared using the comparator function.

Container.Map.Node.Comparator.()

def (self, left, right)

Returns true if left is before right; otherwise returns false .

Container.Map.Node.Comparator.comparator

null

Comparison function.

Container.Map.Node.Comparator.getComparator

def (const self)

Returns the comparison function used by the strategy.

Container.Map.Node.Comparator.new

def (self, comparator)

Creates a new comparator using the given comparator function.

Container.Map.Node.key

none

Node key value.

Container.Map.Node.new

def (self, key, value = none)

Creates a new node with the givens key and value .

Container.Map.Node.value

none

Node mapped value.

Container.Map.[]

def (const self, key)

Returns the value associated to the specified key in the dictionary.

If key is not contained in the dictionary, an instance of Exception.InvalidKey is raised.

Container.Map.[]=

def (self, key, value)

Replaces the value of the element associated to the specified key in the dictionary with the value provided by value.

If key is not contained in the dictionary, a new entry is created with the givens key and value.

Container.Map.clear

def (self)

Removes all the elements of the dictionary.

Container.Map.contains

def (const self, key)

Returns true if the dictionary contains the key key element; otherwise returns false.

Container.Map.count

def (const self, value)

Returns the number of occurrences of the value value in the dictionary.

Container.Map.data

def (const self)

Returns an hash containing each elements of the dictionary.

Container.Map.each

def (const self, func)

Apply the func function to each elements of the dictionary.

If func can take two parameters, the key is passed as first parameter and the value as second parameter; otherwise the key and value of the element are passed using an iterator.

Container.Map.get

def (const self, key, defaultValue = none)

Returns the value associated to the specified key in the dictionary.

If key is not contained in the dictionary, the value of defaultValue is returned instead.

Container.Map.in

def (const self)

Returns an iterator on each element of the dictionary. The elements are provided by an iterator with the key as first element and the value as second element.

def (const self, const key)

Returns true if the dictionary contains the key key element; otherwise returns false.

Container.Map.insert

def (self, key, value)

Inserts value in the dictionary associated with the specified key. If key is already contained in the dictionary, this method has no effect.

Container.Map.isEmpty

def (const self)

Returns true if the dictionary is empty; otherwise returns false.

Container.Map.items

def (const self)

Returns an array containing each elements of the dictionary. The elements are represented by an iterator on the key and the value.

Container.Map.keys

def (const self)

Returns an array containing each keys of the dictionary.

Container.Map.new

def (self, values = {}, comparator = hashKeyCompareOperator)

Creates a new instance of Container.Map. If values is given, the dictionary will be initialized with the given values. The comparator function can be overloaded to change the key sorting behaviour of the dictionary. By default, the same behaviour than the hash is used.

Container.Map.remove

def (self, key)

Removes the element associated to the specified key in the dictionary.

If key is not contained in the dictionary, false is returned; otherwise true is returned.

Container.Map.root

null

Root element node.

Container.Map.set

def (self, key, value)

Replaces the value of the element associated to the specified key in the dictionary with the value provided by value.

If key is not contained in the dictionary, a new entry is created with the givens key and value.

Container.Map.size

def (const self)

Returns the number of elements in the dictionary.

Container.Map.toArray

def (const self)

Converts the dictionary to an array.

Same as keys.

Container.Map.toHash

def (const self)

Converts the dictionary to an hash.

Same as data.

Container.Map.values

def (const self)

Returns an array containing each values of the dictionary.