LisaacTM Platform

SIMPLE_DICTIONARY


2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag
Basic dictionaries (assymmetry value / key) (class akin to DOUBLE_DICTIONARY)
Inherit/Insert Summary
parent_dictionary
parent_traversable
parent_object No developed.
 
Constructor Summary
create
 
Counting:
count
Actual count of stored elements. Number of available indices.
See also is_empty, lower, upper.
is_empty
Is it empty? Is collection empty ?
See also count.
 
Basic access:
has
Is there a value currently associated with key k?
See also fast_has, at.
at
Return the value associated to key k.
See also fast_at, reference_at, has.
reference_at
Return NULL or the value associated with key k. Actually, this feature is useful when the type of values (the type V) is a reference type, to avoid using has just followed by at to get the corresponding value.
See also fast_reference_at, at, has.
fast_has
Is there a value currently associated with key k? Using basic = for comparison.
See also has, at, fast_at.
fast_at
Return the value associated to key k using basic = for comparison.
See also at, reference_at, fast_reference_at.
fast_reference_at
Same work as reference_at, but basic = is used for comparison.
See also reference_at, at, has.
 
Modification.
put to
Change some existing entry or add the new one. If there is as yet no key k in the dictionary, enter it with item v. Otherwise overwrite the item associated with key k. As the put procedure actually uses is_equal, you may consider to use fast_put for expanded objects as well while trying to get the very best performances.
See also fast_put, add.
fast_put to
Same job as put, but uses basic = for comparison.
See also put, add.
add to
To add a new entry k with its associated value v. Actually, this is equivalent to call put, but it may run a little bit faster.
See also put, fast_put.
 
Looking and searching some value:
occurrences
Number of occurrences using is_equal for comparison.
See also fast_occurrences, fast_has, has.
fast_occurrences
Number of occurrences using basic = for comparison.
See also occurrences, fast_has, has.
key_at
Retrieve the key used for value v using is_equal for comparison.
See also fast_key_at, at.
fast_key_at
Retrieve the key used for value v using = for comparison.
See also key_at, at.
 
Removing:
remove
Remove entry k (which may exist or not before this call). As the remove procedure actually uses is_equal, you may consider to use fast_remove for expanded objects as well while trying to get the very best performances.
See also fast_remove, clear_count.
fast_remove
Same job as remove, but uses basic = for comparison.
See also remove, clear_count.
clear_count
Discard all items (is_empty is True after that call). The internal capacity is not changed by this call.
See also clear_count_and_capacity, remove.
clear_count_and_capacity
Discard all items (is_empty is True after that call). The internal capacity may also be reduced after this call.
See also clear_count, remove.
capacity
Approximation of the actual internal storage capacity. The capacity will grow automatically when needed (i.e. capacity is not a limit for the number of values stored). Also note that the capacity value may not be always accurate depending of the implementation (anyway, this capacity value is at least equals to count).
 
To provide iterating facilities:
lower
Minimum index.
See also upper, valid_index, item.
upper
Maximum index.
See also lower, valid_index, item.
item
Item at the corresponding index i.
See also lower, upper, valid_index.
first
The very first item.
See also last, item.
last
The last item.
See also first, item.
key
key_map_in
Append in buffer, all available keys (this may be useful to speed up the traversal).
See also item_map_in.
item_map_in
Append in buffer, all available items (this may be useful to speed up the traversal).
See also key_map_in.
 
Comparaison.
Infix '=='
Do both dictionaries have the same set of associations? Keys are compared with is_equal and values are comnpared with the basic = operator.
See also is_equal_map.
is_equal_map
Do both dictionaries have the same set of associations? Both keys and values are compared with is_equal.
See also is_equal.
copy
Reinitialize by copying all associations of other.
 
Agents based features:
do_all
Apply action to every (V, K) associations of Current.
See also for_all, exist.
foreach_pair
foreach_key
foreach_key until
foreach_key while
foreach_value
foreach_value until
foreach_value while
for_all
Do all (V, K) associations satisfy test?
See also do_all, exist.
exists
Does at least one (V, K) association satisfy test?
See also for_all, do_all.
 
Other features:
internal_key
Retrieve the internal key object which correspond to the existing entry k (the one memorized into the Current dictionary).
See also has, fast_has.
 
Creation.
make
Creates an empty dictionary.
 


key_safe_equal with
Because keys are never NULL, we do not rely on the SAFE_EQUAL class.
 
Indexing:
valid_index
True when i is valid (i.e., inside actual bounds).
See also lower, upper, item.
 
Iterate:
iterate
iterate_index
iterate_increment
iterate_index increment
iterate_reverse
 

Inherit/Insert Detail

parent_dictionary

.../base/collection/low_level/simple_dictionary.li line #13

Section:
Inherit

Profile:
+ SelfSELFparent_dictionary :Expanded  DICTIONARYVK)

parent_traversable

.../base/collection/low_level/dictionary.li line #19

Section:
Inherit

Profile:
+ SelfSELFparent_traversable :Expanded  TRAVERSABLEV)

parent_object

.../base/property/traversable.li line #28

Section:
Inherit

Profile:
- SelfSELFparent_object : OBJECT

Constructor Detail

create

.../base/collection/low_level/dictionary.li line #645

Section:
Public

Profile:
- SelfSELFcreate : SELF

Counting:

count

.../base/collection/low_level/dictionary.li line #27

Section:
Public

Profile:
- SelfSELFcount : INTEGER

Description:
Actual count of stored elements. Number of available indices.
See also is_empty, lower, upper.

is_empty

.../base/collection/low_level/dictionary.li line #34

Section:
Public

Profile:
- SelfSELFis_empty : BOOLEAN

Description:
Is it empty? Is collection empty ?
See also count.

Basic access:

has

.../base/collection/low_level/dictionary.li line #41

Section:
Public

Profile:
- SelfSELFhas   k : KBOOLEAN

Description:
Is there a value currently associated with key k?
See also fast_has, at.

at

.../base/collection/low_level/dictionary.li line #53

Section:
Public

Profile:
- SelfSELFat   k : KV

Description:
Return the value associated to key k.
See also fast_at, reference_at, has.

reference_at

.../base/collection/low_level/dictionary.li line #66

Section:
Public

Profile:
- SelfSELFreference_at   k : KV

Description:
Return NULL or the value associated with key k. Actually, this feature is useful when the type of values (the type V) is a reference type, to avoid using has just followed by at to get the corresponding value.
See also fast_reference_at, at, has.

fast_has

.../base/collection/low_level/dictionary.li line #86

Section:
Public

Profile:
- SelfSELFfast_has   k : KBOOLEAN

Description:
Is there a value currently associated with key k? Using basic = for comparison.
See also has, at, fast_at.

fast_at

.../base/collection/low_level/dictionary.li line #99

Section:
Public

Profile:
- SelfSELFfast_at   k : KV

Description:
Return the value associated to key k using basic = for comparison.
See also at, reference_at, fast_reference_at.

fast_reference_at

.../base/collection/low_level/dictionary.li line #112

Section:
Public

Profile:
- SelfSELFfast_reference_at   k : KV

Description:
Same work as reference_at, but basic = is used for comparison.
See also reference_at, at, has.

Modification.

put to

.../base/collection/low_level/dictionary.li line #134

Section:
Public

Profile:
- SelfSELFput   v : V  to   k : K

Description:
Change some existing entry or add the new one. If there is as yet no key k in the dictionary, enter it with item v. Otherwise overwrite the item associated with key k. As the put procedure actually uses is_equal, you may consider to use fast_put for expanded objects as well while trying to get the very best performances.
See also fast_put, add.

fast_put to

.../base/collection/low_level/dictionary.li line #153

Section:
Public

Profile:
- SelfSELFfast_put   v : V  to   k : K

Description:
Same job as put, but uses basic = for comparison.
See also put, add.

add to

.../base/collection/low_level/dictionary.li line #167

Section:
Public

Profile:
- SelfSELFadd   v : V  to   k : K

Description:
To add a new entry k with its associated value v. Actually, this is equivalent to call put, but it may run a little bit faster.
See also put, fast_put.

Looking and searching some value:

occurrences

.../base/collection/low_level/dictionary.li line #187

Section:
Public

Profile:
- SelfSELFoccurrences   v : VINTEGER

Description:
Number of occurrences using is_equal for comparison.
See also fast_occurrences, fast_has, has.

fast_occurrences

.../base/collection/low_level/dictionary.li line #207

Section:
Public

Profile:
- SelfSELFfast_occurrences   v : VINTEGER

Description:
Number of occurrences using basic = for comparison.
See also occurrences, fast_has, has.

key_at

.../base/collection/low_level/dictionary.li line #226

Section:
Public

Profile:
- SelfSELFkey_at   v : VK

Description:
Retrieve the key used for value v using is_equal for comparison.
See also fast_key_at, at.

fast_key_at

.../base/collection/low_level/dictionary.li line #246

Section:
Public

Profile:
- SelfSELFfast_key_at   v : VK

Description:
Retrieve the key used for value v using = for comparison.
See also key_at, at.

Removing:

remove

.../base/collection/low_level/dictionary.li line #269

Section:
Public

Profile:
- SelfSELFremove   k : K

Description:
Remove entry k (which may exist or not before this call). As the remove procedure actually uses is_equal, you may consider to use fast_remove for expanded objects as well while trying to get the very best performances.
See also fast_remove, clear_count.

fast_remove

.../base/collection/low_level/dictionary.li line #286

Section:
Public

Profile:
- SelfSELFfast_remove   k : K

Description:
Same job as remove, but uses basic = for comparison.
See also remove, clear_count.

clear_count

.../base/collection/low_level/dictionary.li line #300

Section:
Public

Profile:
- SelfSELFclear_count 

Description:
Discard all items (is_empty is True after that call). The internal capacity is not changed by this call.
See also clear_count_and_capacity, remove.

clear_count_and_capacity

.../base/collection/low_level/dictionary.li line #313

Section:
Public

Profile:
- SelfSELFclear_count_and_capacity 

Description:
Discard all items (is_empty is True after that call). The internal capacity may also be reduced after this call.
See also clear_count, remove.

capacity

.../base/collection/low_level/dictionary.li line #326

Section:
Public

Profile:
- SelfSELFcapacity : INTEGER

Description:
Approximation of the actual internal storage capacity. The capacity will grow automatically when needed (i.e. capacity is not a limit for the number of values stored). Also note that the capacity value may not be always accurate depending of the implementation (anyway, this capacity value is at least equals to count).

To provide iterating facilities:

lower

.../base/collection/low_level/dictionary.li line #342

Section:
Public

Profile:
- SelfSELFlower : INTEGER

Description:
Minimum index.
See also upper, valid_index, item.

upper

.../base/collection/low_level/dictionary.li line #344

Section:
Public

Profile:
- SelfSELFupper : INTEGER

Description:
Maximum index.
See also lower, valid_index, item.

item

.../base/collection/low_level/dictionary.li line #352

Section:
Public

Profile:
- SelfSELFitem   i : INTEGERV

Description:
Item at the corresponding index i.
See also lower, upper, valid_index.

first

.../base/collection/low_level/dictionary.li line #362

Section:
Public

Profile:
- SelfSELFfirst : V

Description:
The very first item.
See also last, item.

last

.../base/collection/low_level/dictionary.li line #364

Section:
Public

Profile:
- SelfSELFlast : V

Description:
The last item.
See also first, item.

key

.../base/collection/low_level/dictionary.li line #366

Section:
Public

Profile:
- SelfSELFkey   index : INTEGERK

key_map_in

.../base/collection/low_level/dictionary.li line #379

Section:
Public

Profile:
- SelfSELFkey_map_in   buffer : COLLECTIONK)

Description:
Append in buffer, all available keys (this may be useful to speed up the traversal).
See also item_map_in.

item_map_in

.../base/collection/low_level/dictionary.li line #399

Section:
Public

Profile:
- SelfSELFitem_map_in   buffer : COLLECTIONV)

Description:
Append in buffer, all available items (this may be useful to speed up the traversal).
See also key_map_in.

Comparaison.

Infix '=='

.../base/collection/low_level/dictionary.li line #423

Section:
Public

Profile:
- SelfSELF== '  other : SELFBOOLEAN

Description:
Do both dictionaries have the same set of associations? Keys are compared with is_equal and values are comnpared with the basic = operator.
See also is_equal_map.

is_equal_map

.../base/collection/low_level/dictionary.li line #455

Section:
Public

Profile:
- SelfSELFis_equal_map   other : SELFBOOLEAN

Description:
Do both dictionaries have the same set of associations? Both keys and values are compared with is_equal.
See also is_equal.

copy

.../base/collection/low_level/dictionary.li line #486

Section:
Public

Profile:
- SelfSELFcopy   other : SELF

Description:
Reinitialize by copying all associations of other.

Agents based features:

do_all

.../base/collection/low_level/dictionary.li line #503

Section:
Public

Profile:
- SelfSELFdo_all   action :{VK); }

Description:
Apply action to every (V, K) associations of Current.
See also for_all, exist.

foreach_pair

.../base/collection/low_level/dictionary.li line #520

Section:
Public

Profile:
- SelfSELFforeach_pair   action :{KV); }

foreach_key

.../base/collection/low_level/dictionary.li line #527

Section:
Public

Profile:
- SelfSELFforeach_key   action :{ K; }

foreach_key until

.../base/collection/low_level/dictionary.li line #534

Section:
Public

Profile:
- SelfSELFforeach_key   action :{ K; }  until   test :{ K;  BOOLEAN}

foreach_key while

.../base/collection/low_level/dictionary.li line #544

Section:
Public

Profile:
- SelfSELFforeach_key   action :{ K; }  while   test :{ K;  BOOLEAN}

foreach_value

.../base/collection/low_level/dictionary.li line #554

Section:
Public

Profile:
- SelfSELFforeach_value   action :{ V; }

foreach_value until

.../base/collection/low_level/dictionary.li line #561

Section:
Public

Profile:
- SelfSELFforeach_value   action :{ V; }  until   test :{ V;  BOOLEAN}

foreach_value while

.../base/collection/low_level/dictionary.li line #571

Section:
Public

Profile:
- SelfSELFforeach_value   action :{ V; }  while   test :{ V;  BOOLEAN}

for_all

.../base/collection/low_level/dictionary.li line #581

Section:
Public

Profile:
- SelfSELFfor_all   test :{VK); }BOOLEAN

Description:
Do all (V, K) associations satisfy test?
See also do_all, exist.

exists

.../base/collection/low_level/dictionary.li line #601

Section:
Public

Profile:
- SelfSELFexists   test :{VK); }BOOLEAN

Description:
Does at least one (V, K) association satisfy test?
See also for_all, do_all.

Other features:

internal_key

.../base/collection/low_level/dictionary.li line #624

Section:
Public

Profile:
- SelfSELFinternal_key   k : KK

Description:
Retrieve the internal key object which correspond to the existing entry k (the one memorized into the Current dictionary).
See also has, fast_has.

Creation.

make

.../base/collection/low_level/dictionary.li line #653

Section:
Public

Profile:
- SelfSELFmake 

Description:
Creates an empty dictionary.




key_safe_equal with

.../base/collection/low_level/dictionary.li line #666

Section:
Public

Profile:
- SelfSELFkey_safe_equal   k1 : K  with   k2 : KBOOLEAN

Description:
Because keys are never NULL, we do not rely on the SAFE_EQUAL class.

Indexing:

valid_index

.../base/property/traversable.li line #54

Section:
Public

Profile:
- SelfSELFvalid_index   i : INTEGERBOOLEAN

Description:
True when i is valid (i.e., inside actual bounds).
See also lower, upper, item.

Iterate:

iterate

.../base/property/traversable.li line #140

Section:
Public

Profile:
- SelfSELFiterate : ITERATORV)

iterate_index

.../base/property/traversable.li line #142

Section:
Public

Profile:
- SelfSELFiterate_index   idx : INTEGERITERATORV)

iterate_increment

.../base/property/traversable.li line #145

Section:
Public

Profile:
- SelfSELFiterate_increment   inc : INTEGERITERATORV)

iterate_index increment

.../base/property/traversable.li line #148

Section:
Public

Profile:
- SelfSELFiterate_index   idx : INTEGER  increment   inc : INTEGERITERATORV)

iterate_reverse

.../base/property/traversable.li line #151

Section:
Public

Profile:
- SelfSELFiterate_reverse : ITERATORV)