Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collections (in particular, hashmaps) #527

Draft
wants to merge 154 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
08a8504
Create a builtin hash function for strings.
charlesstaats Dec 20, 2023
a3eeb6f
Merge branch 'master' into datastructures
charlesstaats Dec 20, 2023
e3ad96f
Unnest nested function in C++ hash
charlesstaats Dec 22, 2023
e6dda67
Minor cleanup
charlesstaats Dec 23, 2023
e72fdeb
dummy parse from Andy
charlesstaats Dec 29, 2023
bd149c6
translate decdec to formal
charlesstaats Jan 4, 2024
7958460
checkpoint
charlesstaats Jan 8, 2024
26b403c
Merge branch 'template' into datastructures
charlesstaats Feb 2, 2024
b6d1daf
Queue implementations (wholly untested).
charlesstaats Feb 3, 2024
18f9b5a
linkedlist (untested, probably buggy)
charlesstaats Feb 4, 2024
da9fd36
improved queue naming convention and overloading
charlesstaats Feb 4, 2024
40a9d72
Merge branch 'template' into datastructures
charlesstaats Feb 13, 2024
d0fb074
Partially written test for queue
charlesstaats Feb 14, 2024
972a1a0
Added naive version of linkedlist to help with testing.
charlesstaats Feb 14, 2024
c34c691
Successful test of Queue
charlesstaats Feb 14, 2024
81e6924
Debugging linkedlist.
charlesstaats Feb 14, 2024
e8de9d3
LinkedList appears to be fixed.
charlesstaats Feb 14, 2024
3ce6514
Made linkedlistTest less verbose
charlesstaats Feb 14, 2024
8289e95
Moved linkedlist to base/.
charlesstaats Feb 14, 2024
ad80222
Remove outdated comment.
charlesstaats Feb 14, 2024
a0b297b
Add datastructures tests to makefile
charlesstaats Feb 14, 2024
d35fe42
Add some generated files to gitignore.
charlesstaats Feb 15, 2024
da1d93c
Add hash function for integer arrays.
charlesstaats Feb 18, 2024
8aa3bf3
Partial spaytree implementation.
charlesstaats Feb 20, 2024
c4a218e
Add SortedSet interface and reference implementation.
charlesstaats Feb 21, 2024
cca1983
Test NaiveSortedSet (and fix bugs).
charlesstaats Feb 25, 2024
8697634
Set of small positive ints (using bool[]).
charlesstaats Feb 25, 2024
71480ff
Splaytree with preliminary testing.
charlesstaats Feb 26, 2024
b0408a8
More thorough splaytree testing.
charlesstaats Mar 1, 2024
4c385fa
Preliminary (non-working) hashing code
charlesstaats Mar 11, 2024
f19d7a6
git subrepo clone (merge) https://github.com/google/highwayhash.git h…
charlesstaats Mar 11, 2024
67275f1
Using HighwayHash DOESN'T MAKE
charlesstaats Mar 12, 2024
b439562
Merge branch 'template' into datastructures
charlesstaats Mar 20, 2024
15f11ad
Revert "Initialize structs declared within templated imports."
charlesstaats Mar 20, 2024
75068dc
Merge branch 'master' into hashing
charlesstaats Mar 25, 2024
351663b
Merge branch 'template' into hashing
charlesstaats Mar 25, 2024
758ddf5
Increment version to 2.90.
johncbowman Mar 25, 2024
03bd5a0
Add support for highwayhash to Makefile.in.
johncbowman Mar 29, 2024
0653d61
Make highwayhash-based hashing work.
charlesstaats Mar 31, 2024
72523f3
Rename insert->add, replace->update.
charlesstaats Mar 31, 2024
8bb2306
Merge branch 'hashing' into datastructures
charlesstaats Mar 31, 2024
85f2905
Delete now-redundant tests.
charlesstaats Mar 31, 2024
0793ae1
Hashset implementation (untested, probably buggy).
charlesstaats Mar 31, 2024
b156df6
Fix bug in linkedlist.
charlesstaats Mar 31, 2024
45c6274
Working hashset with test.
charlesstaats Mar 31, 2024
5decacc
Make Set.delete return the deleted item.
charlesstaats Apr 8, 2024
518090a
Add templated pair.
charlesstaats Apr 8, 2024
1afa51b
Naive map implementation and sanity test.
charlesstaats Apr 8, 2024
5b81dab
Minor comment improvement.
charlesstaats Apr 12, 2024
f7d8f82
Hashmap with test
charlesstaats Apr 12, 2024
e72fa85
Basic changes.
charlesstaats Jul 30, 2024
7363682
Add example code for (theoretical) autounravel.
charlesstaats Jul 31, 2024
decd5af
Set clang-format to 80 columns.
charlesstaats Dec 18, 2024
d858b21
Merge branch 'autounravel' into autounravelWithDatastructures
charlesstaats Dec 20, 2024
e69ba85
WIP: Repset and hash implementation
charlesstaats Dec 21, 2024
22e30df
Merge branch 'autounravel' into autounravelWithDatastructures
charlesstaats Dec 25, 2024
577140f
Repset and hashrepset implementation.
charlesstaats Dec 26, 2024
270d841
Allow . notation to access modules in directories.
charlesstaats Dec 26, 2024
38619cb
Use hash method rather than hash function in hashrepset.
charlesstaats Dec 27, 2024
1eeafba
Merge branch 'master' into autounravel.
johncbowman Jan 2, 2025
6cbc5cc
Add roadmap comment for templated imports.
ahammerl Jan 3, 2025
35739e8
BROKEN: Working toward better implementation for templated imports.
charlesstaats Jan 3, 2025
6581da3
BROKEN: Minimal changes to get it to compile.
ahammerl Jan 3, 2025
288595d
Untested function `usableInTemplate` added to dec.cc.
charlesstaats Jan 8, 2025
d019ea7
Debugging: Print out translation-time info about specified type.
charlesstaats Jan 8, 2025
d27f76e
Minor improvements to usableInTemplate function.
charlesstaats Jan 8, 2025
a55323c
Switch to namedTy from namedTyEntry.
charlesstaats Jan 10, 2025
a0e6929
Add comment.
charlesstaats Jan 14, 2025
c2288ec
Apparently working solution (needs refactor).
charlesstaats Jan 16, 2025
31790ad
Add test for passing parameters through multiple templated imports.
charlesstaats Jan 16, 2025
6b4139f
Merge branch 'autounravel' into 508-error-compiling-nested-template-i…
charlesstaats Jan 16, 2025
06a4dcd
Guard boost stacktrace by DEBUG_CSTACKTRACE macro and add comment.
charlesstaats Jan 16, 2025
7ba2a1b
Clean up code a bit.
charlesstaats Jan 16, 2025
ec4a6a1
Clean up and document push/pop parents.
charlesstaats Jan 16, 2025
080dd33
Simplify loadModuleExp class.
charlesstaats Jan 16, 2025
e823fe5
Remove `transAsRecordBody` which did very little.
charlesstaats Jan 16, 2025
c4f4aac
Remove transAsTemplatedRecordBody.
charlesstaats Jan 16, 2025
35dc7ec
Add comment.
charlesstaats Jan 16, 2025
9ebcd49
Improve error message.
charlesstaats Jan 16, 2025
f952b25
Move encodeParent into trans::coder class.
charlesstaats Jan 18, 2025
7efbd13
Non-statically nested types cannot be used in templates.
charlesstaats Jan 18, 2025
d9f368a
Omit unneeded getLocation() before encode().
charlesstaats Jan 20, 2025
943f3f4
Change some "0"s to "nullptr".
charlesstaats Jan 21, 2025
63cb530
Remove unused function from dec.cc.
charlesstaats Jan 21, 2025
a1e4ee6
Show error if module is re-imported with wrong param names after corr…
charlesstaats Jan 22, 2025
b528881
Merge branch 'master' into 508-error-compiling-nested-template-imports.
johncbowman Jan 22, 2025
6434f9a
Add errorFreeTestTemplate.asy.
charlesstaats Jan 22, 2025
bf139c1
Minor comment improvements.
charlesstaats Jan 22, 2025
65239b3
WIP: Working on privacy commit.
charlesstaats Jan 23, 2025
a035168
Correct one case of privacy enforcement.
charlesstaats Jan 23, 2025
bc8fb8f
Return to using record in entry rather than frame for permissions.
charlesstaats Jan 24, 2025
e10634c
Fix privacy issue with overloaded unravel.
charlesstaats Jan 24, 2025
0e52a52
Correct behavior when privately unraveling type.
charlesstaats Jan 24, 2025
fda03ac
Correct private wildcard unraveling.
charlesstaats Jan 24, 2025
d192c42
Make fields autounraveled from private types private.
charlesstaats Jan 24, 2025
ceb538d
Make received template parameters private.
charlesstaats Jan 24, 2025
304ac9e
Merge branch 'privacy' into autounravelWithDatastructures
charlesstaats Jan 24, 2025
97bd44a
Use "." as "/" in unquoted imports to specify paths.
charlesstaats Jan 26, 2025
188fdd0
Merge branch 'master' into autounravelWithDatastructures
charlesstaats Jan 29, 2025
f226903
Add hashmap.asy, map.asy, and tests.
charlesstaats Jan 30, 2025
e719261
Minor improvements to collections.map.
charlesstaats Jan 30, 2025
5200291
Merge branch 'master' into autounravelWithDatastructures
charlesstaats Jan 30, 2025
813098d
Comment improvements in collections.map.
charlesstaats Jan 30, 2025
3b74ad9
WIP: From Andy's work: introduce operator[], string.hash.
charlesstaats Jan 30, 2025
fba7022
Convert operator []= to operator [=].
charlesstaats Jan 31, 2025
a770106
Improve error message.
charlesstaats Jan 31, 2025
b80c2ba
Apparently working implementation of hashmap and operator[].
charlesstaats Feb 4, 2025
db091bf
Delete commented-out code.
charlesstaats Feb 5, 2025
b22ae20
Use highway hash for string.hash method.
charlesstaats Feb 5, 2025
3f12931
Add test for operator[] and operator[=].
charlesstaats Feb 5, 2025
4e990a7
Add int.hash method; line length reformatting.
charlesstaats Feb 6, 2025
473c89d
Add real.hash method.
charlesstaats Feb 6, 2025
3662f2f
Fix operator[=] evaluation order.
charlesstaats Feb 8, 2025
3ba3dff
Refactored extendedForStm::trans.
charlesstaats Feb 8, 2025
4ca4f6b
Introduce LoopType enum for extendedForLoop.
charlesstaats Feb 9, 2025
de5547f
Add test for hash functions.
charlesstaats Feb 14, 2025
ea4aa07
Add more tests for side effect order in brackets expressions.
charlesstaats Feb 14, 2025
119e977
Loosen concurrency requirements when iterating over hashmap.
charlesstaats Feb 15, 2025
ed72247
Get operator iter more or less working.
charlesstaats Feb 17, 2025
11f37a3
Clean up iteration implementation; add tests.
charlesstaats Feb 18, 2025
24f9d8f
Add comments
charlesstaats Feb 19, 2025
9330766
Improve error messages.
charlesstaats Feb 19, 2025
bf1c121
Cache some symbols as static const variables.
charlesstaats Feb 19, 2025
c6644a3
Merge branch 'operator_iter' into autounravelWithDatastructures
charlesstaats Feb 20, 2025
2fcbab9
Merge branch 'master' into autounravelWithDatastructures
charlesstaats Feb 20, 2025
5d0d321
Eliminate completed TODO comment.
charlesstaats Feb 20, 2025
ecbe5ba
Improve error suppression framework.
charlesstaats Feb 20, 2025
e670bab
Rename / move / delete template files.
charlesstaats Feb 20, 2025
360702d
Use operator iter in hashmaps and other collections.
charlesstaats Feb 21, 2025
c7a59cf
First attempt: hashing with cmake.
charlesstaats Feb 21, 2025
377b98b
Second attempt: hashing with cmake.
charlesstaats Feb 22, 2025
f2225f7
Investigate CMAKE_SYSTEM_PROCESSOR on github workflow.
charlesstaats Feb 22, 2025
f6f66a9
Set CMAKE_SYSTEM_PROCESSOR based on CMAKE_SYSTEM_NAME.
charlesstaats Feb 22, 2025
8b80a61
Fallback to host processor.
charlesstaats Feb 22, 2025
3201a3c
More creative ways to determine architecture.
charlesstaats Feb 22, 2025
aa36967
Correct cmake parameter name error.
charlesstaats Feb 22, 2025
4648f21
Add additional output in highwayhash cmake.
charlesstaats Feb 22, 2025
035c5d8
Update queue to use operator iter.
charlesstaats Feb 27, 2025
97f165a
Better document hashTest.
charlesstaats Feb 27, 2025
e3ffad2
Merge branch 'master' into autounravelWithDatastructures
charlesstaats Feb 27, 2025
5692584
Remove boost::span dependency.
johncbowman Feb 28, 2025
7a2f84e
Enforce evaluation order.
johncbowman Feb 28, 2025
228f07b
Fix inefficiency in test cases.
charlesstaats Feb 28, 2025
d3062f0
Use memcpy instead of reinterpret_cast.
charlesstaats Feb 28, 2025
2710dd9
Merge branch 'autounravelWithDatastructures' of https://github.com/ve…
charlesstaats Feb 28, 2025
98400f0
Use evaluate instead of tempExp.
charlesstaats Feb 28, 2025
ff4cbdd
CXX: Change ERROR enum to TY_ERROR since it conflicts with wingdi's E…
jamievlin Mar 1, 2025
2f2699c
HIGHWAYHASH: Add additional files to highwayhash compile targets.
jamievlin Mar 1, 2025
62c3c64
CMAKE: Copy collections base files to cmake build directory.
jamievlin Mar 1, 2025
81064bd
ASY: Add datastructures to cmake asy tests list.
jamievlin Mar 1, 2025
1e3c592
CXX: Remove template asy tests from cmake test list that were removed…
jamievlin Mar 1, 2025
d69ddb3
Fix hasharray error when COMPACT=0.
charlesstaats Mar 2, 2025
279c1f3
Add missing tests to cmake.
charlesstaats Mar 2, 2025
15ba08b
Merge branch 'master' into autounravelWithDatastructures.
johncbowman Mar 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ history
/config.status
/configure
/doc/asy-latex.i*
/doc/asy-latex.hd
/doc/asy.1
/doc/asymptote_html/
/glrender.d.54461
/gsl.symbols.h
/keywords.h
Expand All @@ -66,6 +68,10 @@ history
/types.symbols.h
*.dSYM
.DS_Store
/errors.temp
/base/webgl/asygl.js
/v3dheadertypes.py
/v3dtypes.py

### TeX-related
## Core latex/pdflatex auxiliary files:
Expand Down Expand Up @@ -95,6 +101,9 @@ history
/doc/**/asymptote.*
!/doc/asymptote.texi
/doc/options
/doc/latexusage-?.asy
/doc/latexusage-?.tex
/doc/latexusage-*.pbsdat
.asy_*

## Bibliography auxiliary files (bibtex/biblatex/biber):
Expand Down
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
cmake_minimum_required(VERSION 3.27)

if (NOT CMAKE_HOST_SYSTEM_PROCESSOR)
if (WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")
else()
set(CMAKE_HOST_SYSTEM_PROCESSOR "i386")
endif()
else()
execute_process(COMMAND uname -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
endif()
message(STATUS "Host processor: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
if (NOT CMAKE_SYSTEM_PROCESSOR)
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
endif()

include(cmake-scripts/common.cmake)
include(asy-pkg-version-suffix.cmake OPTIONAL RESULT_VARIABLE ASY_ADDR_VERSION_SUFFIX_FILE)
include(cmake-scripts/options.cmake)
Expand Down
19 changes: 13 additions & 6 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ GCOPTIONS = @GCOPTIONS@
GCLIB = @GCLIB@
GCPPLIB = @GCPPLIB@
GCLIBS = $(GCPPLIB) $(GCLIB)
LFLAGS = @LDFLAGS@
LIBS = $(LFLAGS) @PTHREAD_LIBS@ @GLEW@ @LIBS@ $(GCLIBS) @LSPLIBS@
LFLAGS = @LDFLAGS@ -Lhighwayhash/lib
LIBS = $(LFLAGS) @PTHREAD_LIBS@ @GLEW@ @LIBS@ $(GCLIBS) @LSPLIBS@ -lhighwayhash
CXX_STANDARD = @CXX_STANDARD@
DOSLIBS = $(LIBS) -ltermcap -lwolfssl -lgdi32 -lwinmm -s -static
LSP_BUILD_ROOT=@LSP_BUILD_ROOT@
Expand All @@ -29,7 +29,7 @@ PYUIC ?= pyuic5
# We have to remove OpenGL, threading, GC, etc from this.
SHAREDLIBS = $(filter-out -lglut -GL -pthread $(GCLIBS), $(LIBS))

vpath %.cc prc
vpath %.cc prc highwayhash
vpath %.cc thirdparty_impl/tinyexr_impl/src
vpath %.ui GUI/windows
vpath %.py GUI/pyUIClass
Expand Down Expand Up @@ -59,7 +59,8 @@ COREFILES = $(CAMP) $(SYMBOL_FILES) $(PRC) $(TINYEXR_FILES) \
Delaunay predicates glrender tr shaders jsfile v3dfile \
EXRFiles GLTextures lspserv symbolmaps win32helpers win32pipestream \
win32xdr xstream \
lspdec lspexp lspfundec lspstm
lspdec lspexp lspfundec lspstm \
hashing

FILES = $(COREFILES) main

Expand Down Expand Up @@ -93,7 +94,7 @@ DEFS = @DEFS@ @OPTIONS@ @PTHREAD_CFLAGS@ -DFFTWPP_SINGLE_THREAD -Wall -I.
CFLAGS = @CFLAGS@
OPTS = $(DEFS) @CPPFLAGS@ @CXXFLAGS@ $(CFLAGS) \
-Ibackports/optional/include \
-Iprc/include -I$(LSP_ROOT)/include
-Iprc/include -I$(LSP_ROOT)/include -Ihighwayhash
GLEWOPTS = $(DEFS) @CPPFLAGS@ $(CFLAGS) -DGLEW_NO_GLU -DGLEW_BUILD -O1 -fPIC

# Options for compiling the object files for the shared library.
Expand Down Expand Up @@ -136,7 +137,7 @@ endif

export prefix docdir exampledir mandir infodir INSTALL MAKE DESTDIR TEXI2DVI

asy: base/version.asy $(FILES:=.o) $(XNAME) revision.o @LSPLIB@ @GLEW@
asy: base/version.asy $(FILES:=.o) $(XNAME) revision.o @LSPLIB@ @GLEW@ libhighwayhash.a
$(CXX) $(OPTS) -o $(NAME) $(FILES:=.o) revision.o $(LIBS)

$(XNAME): $(PYFILES)
Expand Down Expand Up @@ -175,6 +176,9 @@ $(LSP_BUILD_ROOT)/liblspcpp.a:
@LSP_CMAKE_OPTIONS@
$(MAKE) -C $(LSP_BUILD_ROOT)

libhighwayhash.a:
cd highwayhash && $(MAKE)

all: asy sty man faq asy-keywords.el

$(GCLIB):
Expand Down Expand Up @@ -372,6 +376,7 @@ clean: FORCE
-cd LspCpp && $(MAKE) distclean
-cd LspCpp && rm -rf liblspcpp.a Makefile CMakeFiles third_party/uri/src/CMakeFiles
-cd tinyexr && $(MAKE) clean
-cd highwayhash && $(MAKE) clean

gc-clean: FORCE clean
-$(MAKE) -C $(GC) clean
Expand All @@ -394,6 +399,8 @@ cleaner: FORCE clean

distclean: FORCE cleaner
cd doc && $(MAKE) distclean
cd highwayhash && $(MAKE) distclean


cleanest: FORCE maintainer-clean
maintainer-clean: FORCE distclean
Expand Down
46 changes: 46 additions & 0 deletions base/collections/enumerate.asy
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
typedef import(T);

from collections.iter(T=T) access Iter_T, Iterable_T;
from collections.genericpair(K=int, V=T) access
Pair_K_V as Pair_int_T,
makePair;
from collections.iter(T=Pair_int_T) access
Iter_T as Iter_Pair_int_T,
Iterable_T as Iterable_Pair_int_T,
Iterable;

Iterable_Pair_int_T enumerate(Iterable_T iterable) {
Iter_Pair_int_T iter() {
int i = 0;
Iter_T it = iterable.operator iter();
Iter_Pair_int_T result;
result.valid = it.valid;
result.get = new Pair_int_T() {
return makePair(i, it.get());
};
result.advance = new void() {
++i;
it.advance();
};
return result;
}
return Iterable(iter);
}

Iterable_Pair_int_T enumerate(T[] array) {
Iter_Pair_int_T iter() {
int i = 0;
Iter_Pair_int_T result;
result.valid = new bool() {
return i < array.length;
};
result.get = new Pair_int_T() {
return makePair(i, array[i]);
};
result.advance = new void() {
++i;
};
return result;
}
return Iterable(iter);
}
20 changes: 20 additions & 0 deletions base/collections/genericpair.asy
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
typedef import(K, V);

struct Pair_K_V {
restricted K k;
restricted V v;
void operator init(K k, V v) {
this.k = k;
this.v = v;
}
autounravel bool operator ==(Pair_K_V a, Pair_K_V b) {
// NOTE: This won't compile if K or V is an array type since == is
// vectorized for arrays. We could locally define a cast operator from
// bool[] to bool, but that would not behave as expected if comparing two
// arrays of different lengths. (We would get an error instead of false.)
return a.k == b.k && a.v == b.v;
}
int hash(); // To be overridden by the user.
}

Pair_K_V makePair(K k, V v) = Pair_K_V;
90 changes: 90 additions & 0 deletions base/collections/hashmap.asy
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
typedef import(K, V);

from collections.map(K=K, V=V) access Map_K_V, Iter_K, Iter_K_V, Iterable_K;
from collections.genericpair(K=K, V=V) access Pair_K_V, makePair;
from collections.hashrepset(T=Pair_K_V) access
HashRepSet_T as HashRepSet_K_V;

private Pair_K_V operator tuple(K k, V v) {
Pair_K_V pair = makePair(k, v);
pair.hash = k.hash;
return pair;
}

struct HashMap_K_V {
struct _ { autounravel restricted Map_K_V map; }

private HashRepSet_K_V pairs = HashRepSet_K_V(
nullT=null,
equiv = new bool(Pair_K_V a, Pair_K_V b) {
// NOTE: This should never be called on a null pair.
return a.k == b.k;
},
isNullT = new bool(Pair_K_V kv) { return alias(kv, null); }
);

void operator init() {
using F = void();
((F)map.operator init)();
}

// TODO: Change "isNullValue" to "isNullValue", and similar.

void operator init(V nullValue, bool isNullValue(V) = null) {
using F = void(V, bool isNullValue(V)=null); // The default value here is ignored.
if (isNullValue == null) {
((F)map.operator init)(nullValue); // Let operator init supply its own default.
} else {
((F)map.operator init)(nullValue, isNullValue);
}
}

map.size = pairs.size;

map.contains = new bool(K key) {
return pairs.contains((key, map.nullValue));
};

map.operator[] = new V(K key) {
Pair_K_V pair = pairs.get((key, map.nullValue));
if (!alias(pair, null)) {
return pair.v;
}
assert(map.isNullValue != null, 'Key not found in map');
return map.nullValue;
};

map.operator [=] = new void(K key, V value) {
if (map.isNullValue != null && map.isNullValue(value)) {
pairs.delete((key, value));
} else {
pairs.update((key, value));
}
};

map.delete = new void(K key) {
Pair_K_V removed = pairs.delete((key, map.nullValue));
assert(!alias(removed, null), 'Nonexistent key cannot be deleted');
};

map.operator iter = new Iter_K() {
Iter_K_V it = pairs.operator iter();
Iter_K result;
result.valid = it.valid;
result.advance = it.advance;
result.get = new K() { return it.get().k; };
return result;
};

autounravel Iterable_K operator cast(HashMap_K_V map) {
return Iterable_K(map.map.operator iter);
}
autounravel K[] operator ecast(HashMap_K_V map) {
return (K[])(Iterable_K)map;
}
autounravel Map_K_V operator cast(HashMap_K_V map) {
return map.map;
}

unravel map;
}
Loading