Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1031039 // Test new, more compact CompactHashMap (OK)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (4677L/28K).

!7

!include #1031040 // CompactHashMap - version using only one array

static new CompactHashMap<S> map1;
static new HashMap<S> map2;

p {
  check();
  repeat 100 {
    repeat 10 {
      putInTwoMaps(map1, map2, aGlobalID(), aGlobalID());
    }
    removeFromTwoMaps(map1, map2, random(keys(map2)));
    check();
  }
  printObjectLayout(map1);
  print("Size: " + n2(deepObjectSize(map1)) + " for " + nElements(map1) + " [table size: " + l(map1.table) + "]");
  print("OK!");
}

svoid check {
  assertEqualsVerbose(map2.size(), map1.size());
  assertEquals(sorted(keys(map2)), sorted(keys(map1)));
  assertEquals(sorted(values(map2)), sorted(values(map1)));
  for (S key : keys(map1))
    assertEquals(map2.get(key), map1.get(key));
  assertNull(map1.get("unknown"));
}

Author comment

Began life as a copy of #1013304

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

-
Snippet ID: #1031039
Snippet name: Test new, more compact CompactHashMap (OK)
Eternal ID of this version: #1031039/4
Text MD5: b89ef394e0783af838eea87f5445fc2f
Transpilation MD5: c3a93be2a3b79e425d313bf85d46f0df
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-25 21:22:46
Source code size: 797 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 319 / 916
Version history: 3 change(s)
Referenced in: