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).

1  
!7
2  
3  
!include #1031040 // CompactHashMap - version using only one array
4  
5  
static new CompactHashMap<S> map1;
6  
static new HashMap<S> map2;
7  
8  
p {
9  
  check();
10  
  repeat 100 {
11  
    repeat 10 {
12  
      putInTwoMaps(map1, map2, aGlobalID(), aGlobalID());
13  
    }
14  
    removeFromTwoMaps(map1, map2, random(keys(map2)));
15  
    check();
16  
  }
17  
  printObjectLayout(map1);
18  
  print("Size: " + n2(deepObjectSize(map1)) + " for " + nElements(map1) + " [table size: " + l(map1.table) + "]");
19  
  print("OK!");
20  
}
21  
22  
svoid check {
23  
  assertEqualsVerbose(map2.size(), map1.size());
24  
  assertEquals(sorted(keys(map2)), sorted(keys(map1)));
25  
  assertEquals(sorted(values(map2)), sorted(values(map1)));
26  
  for (S key : keys(map1))
27  
    assertEquals(map2.get(key), map1.get(key));
28  
  assertNull(map1.get("unknown"));
29  
}

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: 320 / 917
Version history: 3 change(s)
Referenced in: [show references]