TLongLinkedList binarySearch problem?

Issue #47 new
RobPodolski created an issue


TLongList nums = new TLongLinkedList(); nums.add(1L); nums.add(2L); nums.add(3L); nums.add(4L); nums.add(6L); nums.add(7L); nums.add(8L); nums.add(9L); nums.add(10L); nums.sort(); System.out.println(nums.binarySearch(4L));

Gives -4 not 3 as one might expect.

Replace TLongLinkedList with TLongArrayList and you indeed get 3. Can understand that the first one is a linked list of course and the behaviour is kind of to be expected as 5L is missing from nums. Still, this is confusing.

Comments (7)

  1. jimdavies

    This is a bug in a class in the experimental package. Whilst I do agree that it needs to be fixed, and is quite broken, I am prioritising bugs in the core package.

  2. Log in to comment