HashTree is a module that is taken directly from the D2 built-in AA code, cut and pasted, and modified to provide some extra functionality. It has only been tried with D2. The implementation can be used as struct or class template, and hopefully in all the ways that builtin AA can be used. HashTree also has a .clear property, which can ensure that all nodes and memory used by the AA are cleaned up immediatedly.

Usage:

import hash.aatree;

void tryout()
{
   alias aaht!(string, uint)   IntStringAA; // aaht(keytype, valuetype) equivalent to uint[string] built-in AA
   
   IntStringAA   aastruct;

   aastruct["key"] = 111;
   scope(exit)
      aastruct.clear;

   auto val = 111 in aastruct;
   assert(val !is null);
  

   alias HashTree!(string,uint)   IntStringAAClass; // implementation class ( also used by aaht template)

   auto cref = new IntStringAAClass();

   scope(exit)
       cref.clear;

   cref["abc"] = 123;
   val = 123 in cref;
   assert(val !is null);

   

}