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

22
LINES

< > BotCompany Repo | #1030406 // test_LongTreeSetWithComparator (OK)

JavaX fragment (include)

svoid test_LongTreeSetWithComparator() {
  L<Long> list = repF(1000, () -> randomLong());
  TreeSet<Long> set = new((a, b) ->cmp(reverseBytesInLong(a), reverseBytesInLong(b)));
  set.addAll(list);
  LongTreeSet cset = new(set) {
    public int compare(long a, long b) {
      ret cmp(reverseBytesInLong(a), reverseBytesInLong(b));
    }
  };
  
  print(set);
  print(cset);
  assertEquals(asList(set), asList(cset));
  assertEqualsVerbose(l(set), cset.size());
  
  for (Long a : shuffledIterator(list)) {
    set.remove(a);
    cset.remove(a);
    assertEquals(asList(set), asList(cset));
    assertEqualsVerbose(l(set), cset.size());
  }
}

Author comment

Began life as a copy of #1030400

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1030406
Snippet name: test_LongTreeSetWithComparator (OK)
Eternal ID of this version: #1030406/4
Text MD5: 8776625aec3701e2512ab62c7abc7a7f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-12-13 02:22:06
Source code size: 662 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 205 / 243
Version history: 3 change(s)
Referenced in: [show references]