+
Point of view
All features
class HASHED_BIJECTIVE_DICTIONARY [V_ -> HASHABLE, K_ -> HASHABLE]
Summary
Direct parents
Inherit list: BIJECTIVE_DICTIONARY
Insert list: HASH_TABLE_SIZE
Class invariant
Overview
Creation features
{ANY}
  • make
    Create an empty dictionary.
  • with_capacity (medium_size: INTEGER_32)
    May be used to save some execution time if one is sure that storage size will rapidly become really bigger than Default_size.
Features
{ANY}
{HASHED_BIJECTIVE_DICTIONARY}
{ANY}
{}
Implement manifest generic creation:
{}
Looking and searching some value:
{ANY}
To provide iterating facilities:
{ANY}
{}
Implement manifest generic creation:
{}
Counting:
{ANY}
Basic access:
{ANY}
  • infix "@" (k: K_): V_
    The infix notation which is actually a synonym for at.
To provide iterating facilities:
{ANY}
  • lower: INTEGER_32
    Minimum index.
  • upper: INTEGER_32
    Maximum index.
  • first: V_
    The very first item.
  • last: V_
    The last item.
  • key_map_in (buffer: COLLECTION[K_])
    Append in buffer, all available keys (this may be useful to speed up the traversal).
  • item_map_in (buffer: COLLECTION[V_])
    Append in buffer, all available items (this may be useful to speed up the traversal).
  • keys: TRAVERSABLE[K_]
    An iterable of this map keys
  • items: TRAVERSABLE[V_]
    An iterable of this map values Usually returns Current because MAP is TRAVERSABLE.
{ANY}
Display support:
{ANY}
Agents based features:
{ANY}
{}
{}
{ANY}
Other features:
{ANY}
{ANY}
{}
{}
Indexing:
{ANY}
{}
Capacity management: ideally we try to keep the dictionary less than 2/3rd filled
{}
Maximum:
{}
Minimum:
{}
Bits:
{}
count: INTEGER_32
writable attribute
{ANY}
Number of available items in the hoard.
See also is_empty
ensure
  • Result >= 0
has (k: K_): BOOLEAN
effective function
{ANY}
Is there a value currently associated with key k?
See also fast_has, at.
require
  • k /= Void
at (k: K_): V_
effective function
{ANY}
Return the value associated to key k.
See also fast_at, reference_at, has.
require
  • has(k)
reference_at (k: K_): V_
effective function
{ANY}
Return Void or the value associated with key k.
Actually, this feature is useful only 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 with the very best performances.
See also fast_reference_at, at, has.
require
  • k /= Void
  • values_are_not_expanded: Result = Void
ensure
  • has(k) implies Result = at(k)
fast_has (k: K_): BOOLEAN
effective function
{ANY}
Is there a value currently associated with key k?
Using basic = for comparison.
See also has, at, fast_at.
require
  • k /= Void
fast_at (k: K_): V_
effective function
{ANY}
Return the value associated to key k using basic = for comparison.
require
  • fast_has(k)
fast_reference_at (k: K_): V_
effective function
{ANY}
Same work as reference_at, but basic = is used for comparison.
See also reference_at, at, has.
require
  • k /= Void
  • values_are_reference: Result = Void
ensure
  • fast_has(k) implies Result = fast_at(k)
has_value (v: V_): BOOLEAN
effective function
{ANY}
Is there a value v?
require
  • v /= Void
ensure
  • Result implies has(key_at(v))
  • Result = occurrences(v) = 1
key_at (v: V_): K_
effective function
{ANY}
require
  • occurrences(v) = 1
ensure
fast_has_value (v: V_): BOOLEAN
effective function
{ANY}
Is there a value v?
require
  • v /= Void
ensure
  • Result implies fast_has(fast_key_at(v))
  • Result = fast_occurrences(v) = 1
fast_key_at (v: V_): K_
effective function
{ANY}
require
  • fast_occurrences(v) = 1
ensure
  • at(Result) = v
put (v: V_, k: K_)
effective procedure
{ANY}
Change some existing entry or add the new one.
If there as yet no key k in the dictionary, enter it with item v. Otherwise overwrite the item associated with key k.
require
  • bijection_guard_key: has(k) implies key_at(at(k)).is_equal(k)
  • bijection_guard_value: has_value(v) implies key_at(v).is_equal(k)
ensure
  • value_updated: v = fast_at(k)
  • key_updated: k = fast_key_at(v)
add (v: V_, k: K_)
effective procedure
{ANY}
To add a new entry k with its associated value v.
Actually, this is equivalent to call put, but may run a little bit faster.
require
  • not has(k)
  • not has_value(v)
ensure
  • count = 1 + old count
  • v = fast_at(k)
  • k = fast_key_at(v)
remove (k: K_)
effective procedure
{ANY}
Remove entry k (which may exist or not before this call).
require
  • k /= Void
ensure
  • not has(k)
clear_count
effective procedure
{ANY}
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 to select the most appropriate.
require ensure
clear_count_and_capacity
effective procedure
{ANY}
Discard all items (is_empty is True after that call).
The internal capacity may also be reduced after this call. See also clear_count to select the most appropriate.
require ensure
item (index: INTEGER_32): V_
effective function
{ANY}
Item at the corresponding index i.
See also lower, upper, valid_index.
require
  • valid_index(index)
ensure
  • Result = at(key(index))
key (index: INTEGER_32): K_
effective function
{ANY}
require
  • valid_index(index)
ensure
  • at(Result) = item(index)
Default_size: INTEGER_32
is 193
constant attribute
{ANY}
Default size for the storage area in number of items.
internal_key (k: K_): K_
effective function
{ANY}
Retrieve the internal key object which correspond to the existing entry k (the one memorized into the Current dictionary).
require
  • has(k)
ensure
  • internal_key(Result) = Result
  • at(k) = fast_at(Result)
  • Result.is_equal(k)
key_buckets: NATIVE_ARRAY[HASHED_BIJECTIVE_DICTIONARY_NODE[V_, K_]]
writable attribute
The key_buckets storage area is the primary hash table of capacity elements.
To search some key, the first access is done in key_buckets using the remainder of the division of the key hash_code by capacity. In order to try to avoid clashes, capacity is always a prime number (selected using HASHED_CAPACITY).
val_buckets: NATIVE_ARRAY[HASHED_BIJECTIVE_DICTIONARY_NODE[V_, K_]]
writable attribute
The val_buckets storage area is the primary hash table of capacity elements.
To search some value, the first access is done in val_buckets using the remainder of the division of the value hash_code by capacity. In order to try to avoid clashes, capacity is always a prime number (selected using HASHED_CAPACITY).
capacity: INTEGER_32
writable attribute
{ANY}
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).
copy (other: HASHED_BIJECTIVE_DICTIONARY [V_ -> HASHABLE, K_ -> HASHABLE])
effective procedure
{ANY}
require
    • not immutable
    • same_dynamic_type(other)
      • not immutable
      • same_dynamic_type(other)
      • not immutable
      • same_dynamic_type(other)
ensure
  • is_equal(other)
cache_user: INTEGER_32
writable attribute
{}
The last user's external index in range [1 .. count] (see item and valid_index for example) may be saved in cache_user otherwise -1 to indicate that the cache is not active.
When the cache is active, the corresponding index in key_buckets is save in cache_buckets and the corresponding node in cache_node.
cache_node: HASHED_BIJECTIVE_DICTIONARY_NODE[V_, K_]
writable attribute
{}
Meaningful only when cache_user is not -1.
cache_buckets: INTEGER_32
writable attribute
{}
Meaningful only when cache_user is not -1.
free_nodes: WEAK_REFERENCE[HASHED_BIJECTIVE_DICTIONARY_NODE[V_, K_]]
writable attribute
{}
If any, they are ready to be recycled.
set_cache_user (index: INTEGER_32)
effective procedure
{}
Set the internal memory cache (cache_user, cache_node and cache_buckets) to the appropriate valid value.
require ensure
make
effective procedure
{}
Create an empty dictionary.
Internal storage capacity of the dictionary is initialized using the Default_size value. Then, tuning of needed storage capacity is performed automatically according to usage. If you are really sure that your dictionary is always really bigger than Default_size, you may consider to use with_capacity to save some execution time.
ensure
with_capacity (medium_size: INTEGER_32)
effective procedure
{}
May be used to save some execution time if one is sure that storage size will rapidly become really bigger than Default_size.
When first remove occurs, storage size may naturally become smaller than medium_size. Afterall, tuning of storage size is done automatically according to usage.
require
  • medium_size > 0
ensure
basic_make (new_capacity: INTEGER_32)
effective procedure
{}
require ensure
increase_capacity
effective procedure
{}
There is no more free slots: the dictionary must grow.
dispose_node (node: HASHED_BIJECTIVE_DICTIONARY_NODE[V_, K_]): HASHED_BIJECTIVE_DICTIONARY_NODE[V_, K_]
effective function
{}
Add node in the free_nodes list.
require
  • node /= Void
ensure
  • Result = old node.next_key
new_node (v: V_, nv: HASHED_BIJECTIVE_DICTIONARY_NODE[V_, K_], k: K_, nk: HASHED_BIJECTIVE_DICTIONARY_NODE[V_, K_]): HASHED_BIJECTIVE_DICTIONARY_NODE[V_, K_]
effective function
{}
Recycle from free_nodes or create a new one.
ensure
  • Result.val = v
  • Result.next_val = nv
  • Result.key = k
  • Result.next_key = nk
val_buckets_remove (node: HASHED_BIJECTIVE_DICTIONARY_NODE[V_, K_])
effective procedure
{}
require
  • node /= Void
manifest_make (needed_capacity: INTEGER_32)
effective procedure
{}
Manifest creation of a dictionary.
occurrences (v: V_): INTEGER_32
effective function
{ANY}
Number of occurrences using is_equal for comparison.
ensure
  • Result.in_range(0, 1)
  • Result >= 0
fast_occurrences (v: V_): INTEGER_32
effective function
{ANY}
Number of occurrences using basic = for comparison.
See also occurrences, fast_has, has.
ensure
  • Result.in_range(0, 1)
  • Result >= 0
new_iterator_on_items: ITERATOR[V_]
effective function
{ANY}
ensure
  • Result /= Void
  • Result /= Void
  • Result.generation = generation
new_iterator_on_keys: ITERATOR[K_]
effective function
{ANY}
ensure
  • Result /= Void
new_iterator: ITERATOR[TUPLE 2[V_, K_]]
effective function
{ANY}
ensure
  • Result /= Void
key_safe_equal (k1: K_, k2: K_): BOOLEAN
frozen
effective function
{}
Because keys are never Void, we do not rely on the SAFE_EQUAL class.
require
  • k1 /= Void
  • k2 /= Void
val_safe_equal (v1: V_, v2: V_): BOOLEAN
frozen
effective function
{}
Because values are never Void, we do not rely on the SAFE_EQUAL class.
require
  • v1 /= Void
  • v2 /= Void
manifest_put (index: INTEGER_32, v: V_, k: K_)
effective procedure
{}
require
  • v /= Void
  • k /= Void
  • not has(k)
manifest_semicolon_check: INTEGER_32
is 2
constant attribute
{}
Put semicolons between successive value-key pairs.
is_empty: BOOLEAN
effective function
{ANY}
Is it empty?
ensure
  • definition: Result = count = 0
infix "@" (k: K_): V_
frozen
effective function
{ANY}
The infix notation which is actually a synonym for at.
require ensure
  • definition: Result = at(k)
lower: INTEGER_32
is 1
constant attribute
{ANY}
Minimum index.
See also upper, valid_index, item.
upper: INTEGER_32
effective function
{ANY}
Maximum index.
See also lower, valid_index, item.
ensure
first: V_
effective function
{ANY}
The very first item.
See also last, item.
require
  • not is_empty
ensure
  • definition: Result = item(lower)
last: V_
effective function
{ANY}
The last item.
See also first, item.
require
  • not is_empty
ensure
  • definition: Result = item(upper)
key_map_in (buffer: COLLECTION[K_])
effective procedure
{ANY}
Append in buffer, all available keys (this may be useful to speed up the traversal).
See also item_map_in.
require
  • buffer /= Void
ensure
  • buffer.count = count + old buffer.count
item_map_in (buffer: COLLECTION[V_])
effective procedure
{ANY}
Append in buffer, all available items (this may be useful to speed up the traversal).
See also key_map_in.
require
  • buffer /= Void
ensure
  • buffer.count = count + old buffer.count
keys: TRAVERSABLE[K_]
effective function
{ANY}
An iterable of this map keys
ensure
items: TRAVERSABLE[V_]
effective function
{ANY}
An iterable of this map values Usually returns Current because MAP is TRAVERSABLE.
ensure
fast_is_equal (other: HASHED_BIJECTIVE_DICTIONARY [V_ -> HASHABLE, K_ -> HASHABLE]): BOOLEAN
effective function
{ANY}
Do both dictionaries have the same set of associations?
Keys are compared with is_equal and values are compared with the basic = operator.
See also is_equal.
ensure
is_equal (other: HASHED_BIJECTIVE_DICTIONARY [V_ -> HASHABLE, K_ -> HASHABLE]): BOOLEAN
effective function
{ANY}
Do both dictionaries have the same set of associations?
Both keys and values are compared with is_equal.
See also fast_is_equal.
require
    • other /= Void
    • other /= Void
ensure
  • commutative: generating_type = other.generating_type implies Result = other.is_equal(Current)
is_equal_map (other: HASHED_BIJECTIVE_DICTIONARY [V_ -> HASHABLE, K_ -> HASHABLE]): BOOLEAN
effective function
{ANY}
Do both collections have the same lower, upper, and items?
This feature is obsolete: Use `is_equal' instead.
out_in_tagged_out_memory
effective procedure
{ANY}
Append terse printable representation of current object in tagged_out_memory.
require
    • locked: tagged_out_locked
    • locked: tagged_out_locked
ensure
  • still_locked: tagged_out_locked
  • not_cleared: tagged_out_memory.count >= old tagged_out_memory.count
  • append_only: old tagged_out_memory.twin.is_equal(tagged_out_memory.substring(1, old tagged_out_memory.count))
for_each (action: PROCEDURE[TUPLE[TUPLE 2[V_, K_]]])
effective procedure
{ANY}
Apply action to every [V_, K_] associations of Current.
See also for_all, exist.
require
  • action /= Void
do_all (action: ROUTINE[TUPLE[TUPLE 2[V_, K_]]])
frozen
effective procedure
{ANY}
Apply action to every [V_, K_] associations of Current.
This feature is obsolete: This feature is not secure because it accepts a FUNCTION, the result of which is lost. Plese use `for_each` instead.
for_all (test: FUNCTION[TUPLE[TUPLE 2[V_, K_]]]): BOOLEAN
effective function
{ANY}
Do all [V_, K_] associations satisfy test?
See also for_each, exist.
require
  • test /= Void
exists (test: FUNCTION[TUPLE[TUPLE 2[V_, K_]]]): BOOLEAN
effective function
{ANY}
Does at least one [V_, K_] association satisfy test?
See also for_all, for_each.
require
  • test /= Void
aggregate (action: FUNCTION[TUPLE[TUPLE 3[V_, V_, K_], V_]], initial: V_): V_
effective function
{ANY}
Aggregate all the elements starting from the initial value.
See also for_each, for_all, exists.
require
  • action /= Void
keys_memory: DICTIONARY_KEY_TRAVERSER[V_, K_]
writable attribute
{}
_inline_agent43 (v: V_, k: K_)
frozen
effective procedure
{}
enumerate: ENUMERATE[E_]
effective function
{ANY}
get_new_iterator: ITERATOR[E_]
frozen
effective function
{ANY}
This feature is obsolete: Use `new_iterator' instead. This historical SmartEiffel feature is badly named.
generation: INTEGER_32
writable attribute
{ANY}
next_generation
effective procedure
{}
ensure
_inline_agent1 (a: ROUTINE[TUPLE[TUPLE 1[E_]]], e: E_)
frozen
effective procedure
{}
valid_index (i: INTEGER_32): BOOLEAN
effective function
{ANY}
True when i is valid (i.e., inside actual bounds).
See also lower, upper, item.
ensure
prime_number_ceiling (integer: INTEGER_32): INTEGER_32
effective function
{}
A good prime number, large enough, and no smaller than integer.
require
  • is_positive: integer >= 0
ensure
  • Result >= integer.max(1)
prime_capacity (a_capacity: INTEGER_32): INTEGER_32
effective function
{}
require
  • a_capacity >= 0
ensure
  • Result >= a_capacity
should_increase_capacity (a_capacity: INTEGER_32, a_count: INTEGER_32): BOOLEAN
effective function
{}
Maximum_character_code: INTEGER_16
{}
Largest supported code for CHARACTER values.
ensure
  • meaningful: Result >= 127
Maximum_integer_8: INTEGER_8
is 127
constant attribute
{}
Largest supported value of type INTEGER_8.
Maximum_integer_16: INTEGER_16
is 32767
constant attribute
{}
Largest supported value of type INTEGER_16.
Maximum_integer: INTEGER_32
is 2147483647
constant attribute
{}
Largest supported value of type INTEGER/INTEGER_32.
Maximum_integer_32: INTEGER_32
is 2147483647
constant attribute
{}
Largest supported value of type INTEGER/INTEGER_32.
Maximum_integer_64: INTEGER_64
is 9223372036854775807
constant attribute
{}
Largest supported value of type INTEGER_64.
Maximum_real_32: REAL_32
is {REAL_32 3.4028234663852885981170418348451692544e+38}
constant attribute
{}
Largest non-special (no NaNs nor infinity) supported value of type REAL_32.
Maximum_real: REAL_64
{}
Largest non-special (no NaNs nor infinity) supported value of type REAL.
Just to give an idea of this value: 1.79769313486231570....e+308
Maximum_real_64: REAL_64
{}
Largest non-special (no NaNs nor infinity) supported value of type REAL.
Just to give an idea of this value: 1.79769313486231570....e+308
Maximum_real_80: REAL_EXTENDED
{}
Largest supported value of type REAL_80.
ensure
Minimum_character_code: INTEGER_16
{}
Smallest supported code for CHARACTER values.
ensure
  • meaningful: Result <= 0
Minimum_integer_8: INTEGER_8
is -128
constant attribute
{}
Smallest supported value of type INTEGER_8.
Minimum_integer_16: INTEGER_16
is -32768
constant attribute
{}
Smallest supported value of type INTEGER_16.
Minimum_integer: INTEGER_32
is -2147483648
constant attribute
{}
Smallest supported value of type INTEGER/INTEGER_32.
Minimum_integer_32: INTEGER_32
is -2147483648
constant attribute
{}
Smallest supported value of type INTEGER/INTEGER_32.
Minimum_integer_64: INTEGER_64
is -9223372036854775808
constant attribute
{}
Smallest supported value of type INTEGER_64.
Minimum_real_32: REAL_32
is {REAL_32 -3.40282346638528859811704183484516925440e+38}
constant attribute
{}
Smallest non-special (no NaNs nor infinity) supported value of type REAL_32.
Minimum_real: REAL_64
{}
Smallest non-special (no NaNs nor infinity) supported value of type REAL.
Just to give an idea of this value: -1.79769313486231570....e+308
Minimum_real_64: REAL_64
{}
Smallest non-special (no NaNs nor infinity) supported value of type REAL.
Just to give an idea of this value: -1.79769313486231570....e+308
Minimum_real_80: REAL_64
{}
Smallest supported value of type REAL_80.
ensure
  • meaningful: Result <= 0.0
Boolean_bits: INTEGER_32
{}
Number of bits in a value of type BOOLEAN.
ensure
  • meaningful: Result >= 1
Character_bits: INTEGER_32
{}
Number of bits in a value of type CHARACTER.
ensure
Integer_bits: INTEGER_32
{}
Number of bits in a value of type INTEGER.
ensure
  • integer_definition: Result = 32
Real_bits: INTEGER_32
is 64
constant attribute
{}
Number of bits in a value of type REAL.
Pointer_bits: INTEGER_32
{}
Number of bits in a value of type POINTER.