Dict
Parameters
[Key = Dynamic, Value = Dynamic, Hasher = MurMur3Hasher]
Implements an ordered dictionary backed by a Hashtable using the provided hasher. The order of insertion of items is preserved and items can be iterated bidirectionally from the beginning to the end and vice versa.
graph BT
N1["Dict[Key,Value,Hasher]"] -->|inherits| N2["ReverseIterable[Key,Value]"];
N1["Dict[Key,Value,Hasher]"] -->|inherits| N3["Unpackable[Key,Value]"];
Characteristics
Quality | Value |
---|---|
Inherits | ReverseIterable[Key, Value], Unpackable[Key, Value] |
Extends | N/A |
Decorators | #sealed; |
Is enum | false |
Is sealed | true |
Is extern | false |
Type Aliases
DType
DType = Key, Value
ListData
ListData = Pair[Hasher.HashValueType, Pair[Key, Value]]
Subscript
[s Self, key @Key] -> @Value
access the value represented by the provided key. If the key does not exist when getting the value an instance of WrongArgumentException
will be raised. If the key does exist when setting a value the old value will be overridden with the new one.
Methods
construct
construct (s Self, size_hint Len = 0) -> Self
init
init (s Self, size_hint Len = 0) -> Nil
get_iterator
get_iterator (s Self) -> DictIterator[Self]
get_reverse_iterator
get_reverse_iterator (s Self) -> DictIterator[Self]
len
#strict
#Gambol.function.alwaysinline
len (s Self) -> Len
copy
copy (s Self) -> strictly SelfType
keys
keys (s Self) -> List[Key]
values
values (s Self) -> List[Value]
get_value_ptr
get_value_ptr (s Self, key Key) -> PointerToVariable[Value]
key
. If the key does not exist will raise an instance of WrongArgumentException
.
add
add (s Self, key @Key, value @Value) -> Nil
remove
remove (s Self, key @Key) -> Nil
first
first (s Self) -> @DType?
last
last (s Self) -> @DType?
pop
pop (s Self) -> @DType?
str
str (s Self, delimiter: String = `, `, pair_delimiter: String = `: `, quote_begin: String = ```, quote_end: String = ```, enclose_begin: String = `[`, enclose_end: String = `]`) -> String
__erase
__erase (s Self, index Len, list_ptr Pointer) -> Nil
__calculate_index
#Gambol.function.alwaysinline
__calculate_index (s Self, hash_value Hasher.HashValueType) -> Len
__grow_if_necessary
__grow_if_necessary (s Self) -> Nil
Binary Operators
is in
is in (s Self, key @Key) -> Bool
==
== (s Self, o Self) -> Bool
<=
<= (s Self, o Self) -> Bool
o
. In order to be a subset all keys in this dictionary must also exist in o
and the associated values for each key must be equal in both dictinoaries.
<
< (s Self, o Self) -> Bool
o
.
>=
>= (s Self, o Self) -> Bool
o
is a subset of this dictionary.
>
> (s Self, o Self) -> Bool
o
is a proper subset of this dictionary.
|
| (s Self, o Self) -> strictly SelfType
o
. If a key exists in both dictionaries but the values are different the value from o
will be selected.
|=
|= (s Self, o Self) -> Self
o
to this dictionary. If a key already exists in this dictionary then the original value is overridden with the new one.
&
& (s Self, o Self) -> strictly SelfType
o
with equality being defined as both the key and the value being equal
&=
&= (s Self, o Self) -> Self
o
or if it does the associated value is different
-
- (s Self, o Self) -> SelfType
-=
-= (s Self, o Self) -> Self
o
.
^
^ (s Self, o Self) -> SelfType
o
with equality being defined as both the key and the value being equal.
^=
^= (s Self, o Self) -> Self
o
with equality being defined as both the key and the value being equal.
Properties
kInitSize
const global kInitSize Len = 64
kGrowthFactor
const global kGrowthFactor Len = 3
__table
__table List[Pointer](kInitSize)
__len
__len Len
__load
__load Len
__first_ptr
__first_ptr Pointer
__last_ptr
__last_ptr Pointer