text: ikod-containers 0.0.20
  containers library
  To use this package, run the following command in your project's root directory:
  Manual usage
  Put the following dependency into your project's dependences section:
  ikod-containers
  HashMap
  Main differences from language AA:
  - HashMap itself is struct and value (not reference), so any assign
  map2 = map1will copy all data from map1 to map2.
  - HashMap have deprecated "in" operator. Pointer to value in the table is highly unsafe (as stored value location can change on any table mutation). Use
  fetchto test presence and fetch value in single API call intead of
  in.
  - Any method from
  getfamily returns value stored in table, and never - pointer. This is safe.
  Main advantages:
  - It is fast, as it do not allocate on every insert and has optimized storage layout.
  - It inherit
  @nogcand
  @safeproperties from key and value types, so it can be used in
  @safeand
  @nogccode. Note:
  opIndexcan throw exception so it is not @nogc in any case (use fetch or get with default value if you need @nogc)
  - Provide stable iteration over container (you can modify/delete table items while iterating over it).
  You cah find HashMap API docs here
  code sample
  import std.range; import std.algorithm; import ikod.containers.hashmap; static string[] words = [ "hello", "this", "simple", "example", "should", "succeed", "or", "it", "should", "fail" ]; void main() @safe @nogc { HashMap!(string, int) counter; // count words, simplest and fastest way foreach (word; words) { counter[word] = counter.getOrAdd(word, 0) + 1; // getOrAdd() return value from table or add it to table } assert(counter.fetch("hello").ok); // fetch() is replacement to "in": you get "ok" if key in table assert(counter.fetch("hello").value == 1); // and value itself debug assert(counter["hello"] == 1); // opIndex is not @nogc debug assert(counter["should"] == 2); // opIndex is not @nogc assert(counter.contains("hello")); // contains check presence assert(counter.length == words.length - 1); // because "should" counts only once // iterators assert(counter.byKey.count == counter.byValue.count); assert(words.all!(w => counter.contains(w))); // all words in table assert(counter.byValue.sum == words.length); // sum of counters must equals to number of words }
  UnrolledList
  From Wikipedia, the free encyclopedia [*]
  In computer programming, an unrolled linked list is a variation on the linked list which stores multiple elements in each node. It can dramatically increase cache performance, while decreasing the memory overhead associated with storing list metadata such as references. It is related to the B-tree.
  Advantages:
  - Fast, cache-friendly
  - @nogc, @safe
  - sane iterators (unstable and stable iterators supported)
  code sample
  import std.algorithm: equal; import std.range: iota; import ikod.containers.unrolledlist: UnrolledList; void main() @safe @nogc { UnrolledList!int l; // add items foreach(i; 2..50) { l.pushBack(i); // push back } l.pushFront(0); // push front l.insert(1,1); // insert value at arbitrary position // get items assert(l.front == 0); assert(l.back == 49); auto v = l.get(25); // get value at some position. Same as l[25] but @nogc assert(v.ok); assert(v.value == 25); // iterators/ranges auto r = l.unstableRange(); assert(equal(r, iota(50))); }
  - Registered by Igor Khasilev
  - 0.0.20 released 3 months ago
  - ikod/ikod-containers
  - BSL-1
  - Authors:
  -
  - Dependencies:
  - automem
  - Versions:
  - Show all 21 versions
  - Download Stats:
  0 downloads today
  0 downloads this week
  1 downloads this month
  290 downloads total
  - Score:
  - 0.8
  - Short URL:
  - ikod-containers.dub.pm