Package net.thevpc.naru.api.util
Class NaruLongSortedSet
java.lang.Object
net.thevpc.naru.api.util.NaruLongSortedSet
Sorted set of primitive longs, ordered by value.
O(log n) lookup, O(n) insert due to array shift.
Optimized for small-to-medium sets with frequent ordered iteration.
Not thread-safe — synchronize externally.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(long value) booleancontains(long value) longfirst()longget(int index) booleanisEmpty()longlast()booleanremove(long value) intsize()inttailIndex(long fromValue) Returns a view of values >= fromValue, as indices into iteration.long[]toArray()toString()
-
Constructor Details
-
NaruLongSortedSet
public NaruLongSortedSet() -
NaruLongSortedSet
public NaruLongSortedSet(int initialCapacity)
-
-
Method Details
-
add
public boolean add(long value) -
contains
public boolean contains(long value) -
remove
public boolean remove(long value) -
get
public long get(int index) -
first
public long first() -
last
public long last() -
tailIndex
public int tailIndex(long fromValue) Returns a view of values >= fromValue, as indices into iteration. Caller iterates from returned index forward. -
size
public int size() -
isEmpty
public boolean isEmpty() -
toArray
public long[] toArray() -
toString
-