Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
core.internal.newaa
template implementation of associative arrays.
License:
Authors:
Martin Nowak, Steven Schveighoffer, Rainer Schuetze
Source core/internal/newaa.d
derived from rt/aaA.d- immutable int
_aaVersion; - AA version for debuggers, bump whenever changing the layout
- struct
AA(K, V); - AA wrapper
- V[K]
_d_aaNew(K, V)(); - Allocate associative array data. Called for new SomeAA expression.Returns:A new associative array.
Note not supported in CTFE
- size_t
_d_aaLen(K, V)(inout V[K]a); - Determine number of entries in associative array.
Note emulated by the compiler during CTFE
- V*
_d_aaGetY(K, V, T : V1[K1], K1, V1, K2)(auto ref scope Taa, auto ref K2key, out boolfound); - Lookup key in aa. Called only from implementation of (aa[key]) expressions when value is mutable.Parameters:
T aaassociative array K2 keyreference to the key value bool foundreturns whether the key was found or a new entry was added Returns:if key was in the aa, a mutable pointer to the existing value. If key was not in the aa, a mutable pointer to newly inserted value which is set to zero - V*
_aaGetX(K, V, K2, V2)(auto ref scope V[K]a, auto ref K2key, out boolfound, lazy V2v2); - Lookup key in aa. Called only from implementation of require, update and d_aaGetYParameters:
V[K] aassociative array K2 keyreference to the key value bool foundtrue if the value was found V2 v2if key not found, init new value to this (except if type noV2) Returns:if key was in the aa, a mutable pointer to the existing value. If key was not in the aa, a mutable pointer to newly inserted value which is set to v2 or is zero-initialized - auto
_d_aaGetRvalueX(K, V, K2)(inout V[K]aa, auto ref scope K2key);
auto_d_aaGetRvalueX(K, V, K2)(shared(V[K])aa, auto ref scope K2key);
auto_d_aaGetRvalueX(K, V, K2)(shared const(V[K])aa, auto ref scope K2key);
auto_d_aaGetRvalueX(K, V, K2)(immutable(V[K])aa, auto ref scope K2key); - Lookup key in aa. Called only from implementation of (aa[key]) expressions when value is not mutable.Parameters:
V[K] aaassociative array K2 keykey value Returns:pointer to value if present, null otherwise - auto
_aaDup(T : V[K], K, V)(Ta); - Creates a new associative array of the same size and copies the contents of the associative array into it.Parameters:
T aThe associative array. - auto
_d_aaIn(T : V[K], K, V, K2)(inout Ta, auto ref scope K2key); - Lookup key in aa. Called only from implementation of (key in aa) expressions.Parameters:
T aassociative array opaque pointer K2 keyreference to the key value Returns:pointer to value if present, null otherwise - auto
_d_aaDel(T : V[K], K, V, K2)(Ta, auto ref K2key); - Delete entry scope const AA, return true if it was present
- void
_aaClear(K, V)(V[K]a); - Remove all elements from AA.
- V[K]
_aaRehash(K, V)(V[K]a); - Rehash AA
- auto
_aaValues(K, V)(inout V[K]a); - Return a GC allocated array of all values
- auto
_aaKeys(K, V)(inout V[K]a); - Return a GC allocated array of all keys
- int
_d_aaApply(K, V, DG)(inout V[K]a, DGdg); - foreach opApply over all values
Note emulated by the compiler during CTFE
- int
_d_aaApply2(K, V, DG)(inout V[K]a, DGdg); - foreach opApply over all key/value pairs
Note emulated by the compiler during CTFE
- Impl!(K, V)*
_d_assocarrayliteralTX(K, V)(K[]keys, V[]vals); - Construct an associative array of type ti from corresponding keys and values. Called for an AA literal [k1:v1, k2:v2].Parameters:
K[] keysarray of keys V[] valsarray of values Returns:A new associative array opaque pointer, or null ifkeysis empty. - bool
_aaEqual(T : AA!(K, V), K, V)(scope Taa1, scope Taa2); - compares 2 AAs for equality
- bool
_d_aaEqual(K, V)(scope const V[K]a1, scope const V[K]a2); - compares 2 AAs for equality (compiler hook)
- bool
_aaOpEqual(K, V)(scope AA!(K, V)*aa1, scope AA!(K, V)*aa2); - callback from TypeInfo_AssociativeArray.equals (ignore const for now)
- hash_t
_aaGetHash(K, V)(AA!(K, V)*paa); - compute a hash callback from TypeInfo_AssociativeArray.xtoHash (ignore scope const for now)
- struct
AARange(K, V); - aaRange implements a ForwardRange
Copyright © 1999-2025 by the D Language Foundation | Page generated by
Ddoc on Fri Dec 12 14:51:30 2025