copy (HashTable)

Makes a copy of a table, copying all its entries.

Arguments

table0
is the HashTable to copy.

Return values

table1
is the resulting HashTable.

Complexity

O(size)

Example

"sl/hashTable" useFile a: HashTable; a.empty print LF print 34 "element" a.insert 35 "element" a.insert 38 "element" a.insert 40 "bigElement" a.insert b: a copy; a [it:; it.get.key 35 > [it a.eraseIter] when TRUE] enumIter "small" 34 a ! 45 "bigBigElement" b.insert "a:" print LF print a [print LF print TRUE] enum "b:" print LF print b [print LF print TRUE] enum
Output:
TRUE a: { key: 34; value: "small"; } { key: 35; value: "element"; } b: { key: 34; value: "element"; } { key: 35; value: "element"; } { key: 38; value: "element"; } { key: 40; value: "bigElement"; } { key: 45; value: "bigBigElement"; }