fukatani / TreeSet

Python Binary-Tree set like java Treeset.
35 stars 11 forks source link

TreeSet ceiling fails with IndexError #1

Open ishsonya opened 6 years ago

ishsonya commented 6 years ago

Fails when a value for ceilng is greater than any value in tree

a = TreeSet([int(x) for x in '903485034580236'])
a.ceiling(100)
fukatani commented 6 years ago

Thanks for your report. What is your expected behavior? Return None or raise more explicit exception?

jerryqiang commented 5 years ago

hi, you know TreeMap or TreeSet in Java1.8 It has other methods like this: TreeMap<Integer, Integer> map = new TreeMap<>(); map.firstKey(); map.lastKey(); map.ceilingKey(); map.floorKey();

fukatani commented 5 years ago

Those method is for TreeMap and this repository does not support TreeMap. PR is welcome.

TreeSet.ceiling and TreeSet.floor is already supported, and if you want to get first or last element of TreeSet, you can use set[0] and set[-1].