code stringlengths 23 201k | docstring stringlengths 17 96.2k | func_name stringlengths 0 235 | language stringclasses 1
value | repo stringlengths 8 72 | path stringlengths 11 317 | url stringlengths 57 377 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
public static <V> IntMap<V> from(IMap<Number, V> m) {
if (m instanceof IntMap) {
return (IntMap) m.forked();
} else {
return from(m.entries());
}
} | @param m another map
@return a forked copy of the map | from | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public static <V> IntMap<V> from(Collection<Map.Entry<Number, V>> collection) {
IntMap<V> map = new IntMap<V>().linear();
for (Map.Entry<Number, V> entry : collection) {
map = map.put((long) entry.getKey(), entry.getValue());
}
return map.forked();
} | @param collection a collection of {@link java.util.Map.Entry} objects
@return an {@link IntMap} representing the entries in the collection | from | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public static <V> IntMap<V> from(IList<IEntry<Number, V>> list) {
IntMap<V> map = new IntMap<V>().linear();
for (IEntry<Number, V> entry : list) {
map = map.put((long) entry.key(), entry.value());
}
return map.forked();
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | from | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public Comparator<Long> comparator() {
return Comparator.naturalOrder();
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | comparator | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public ToLongFunction<Long> keyHash() {
return HASH;
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | keyHash | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public BiPredicate<Long, Long> keyEquality() {
return Long::equals;
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | keyEquality | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public IntMap<V> slice(long min, long max) {
return slice(min, Bound.INCLUSIVE, max, Bound.EXCLUSIVE);
} | @param min the inclusive minimum key value
@param max the exclusive maximum key value
@return a map representing all entries within {@code [min, max)} | slice | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public IntMap<V> slice(long min, Bound minBound, long max, Bound maxBound) {
min += minBound == Bound.EXCLUSIVE ? 1 : 0;
max += maxBound == Bound.INCLUSIVE ? 1 : 0;
Node<V> negPrime = neg.slice(editor, min, Math.min(-1, max));
Node<V> posPrime = pos.slice(editor, Math.max(0, min), max);
return new ... | @param min the inclusive minimum key value
@param max the exclusive maximum key value
@return a map representing all entries within {@code [min, max)} | slice | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public IntMap<V> merge(IMap<Long, V> b, BinaryOperator<V> mergeFn) {
if (b instanceof IntMap) {
IntMap<V> m = (IntMap<V>) b;
return new IntMap<V>(
IntMapNodes.merge(new Object(), neg, m.neg, mergeFn),
IntMapNodes.merge(new Object(), pos, m.pos, mergeFn),
isLinea... | @param min the inclusive minimum key value
@param max the exclusive maximum key value
@return a map representing all entries within {@code [min, max)} | merge | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public IntMap<V> difference(ISet<Long> keys) {
if (keys instanceof IntSet) {
return difference(((IntSet) keys).m);
} else {
return (IntMap<V>) Maps.difference(this, keys);
}
} | @param min the inclusive minimum key value
@param max the exclusive maximum key value
@return a map representing all entries within {@code [min, max)} | difference | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public IntMap<V> intersection(ISet<Long> keys) {
if (keys instanceof IntSet) {
return intersection(((IntSet) keys).m);
} else {
return (IntMap<V>) Maps.intersection(new IntMap<V>().linear(), this, keys);
}
} | @param min the inclusive minimum key value
@param max the exclusive maximum key value
@return a map representing all entries within {@code [min, max)} | intersection | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public IntMap<V> union(IMap<Long, V> m) {
return merge(m, (BinaryOperator<V>) Maps.MERGE_LAST_WRITE_WINS);
} | @param min the inclusive minimum key value
@param max the exclusive maximum key value
@return a map representing all entries within {@code [min, max)} | union | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public IntMap<V> difference(IMap<Long, ?> b) {
if (b instanceof IntMap) {
IntMap<V> m = (IntMap<V>) b;
Node<V> negPrime = IntMapNodes.difference(new Object(), neg, m.neg);
Node<V> posPrime = IntMapNodes.difference(new Object(), pos, m.pos);
return new IntMap<V>(
negPrim... | @param min the inclusive minimum key value
@param max the exclusive maximum key value
@return a map representing all entries within {@code [min, max)} | difference | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public IntMap<V> intersection(IMap<Long, ?> b) {
if (b instanceof IntMap) {
IntMap<V> m = (IntMap<V>) b;
Node<V> negPrime = IntMapNodes.intersection(new Object(), neg, m.neg);
Node<V> posPrime = IntMapNodes.intersection(new Object(), pos, m.pos);
return new IntMap<V>(
n... | @param min the inclusive minimum key value
@param max the exclusive maximum key value
@return a map representing all entries within {@code [min, max)} | intersection | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public IntMap<V> remove(long key) {
return remove(key, isLinear() ? editor : new Object());
} | @return an updated map that does not contain {@code key} | remove | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public IntMap<V> remove(long key, Object editor) {
if (key < 0) {
Node<V> negPrime = neg.remove(editor, key);
if (neg == negPrime) {
return this;
} else if (isLinear()) {
super.hash = -1;
neg = negPrime;
return this;
} else {
return new IntMap<V>(negPr... | @return an updated map that does not contain {@code key} | remove | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public IntMap<V> remove(Long key) {
return remove((long) key);
} | @return an updated map that does not contain {@code key} | remove | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public <U> IntMap<U> mapValues(BiFunction<Long, V, U> f) {
Object editor = new Object();
return new IntMap<>(neg.mapVals(editor, f), pos.mapVals(editor, f), isLinear());
} | @return an updated map that does not contain {@code key} | mapValues | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public Optional<V> get(long key) {
Object o = (key < 0 ? neg : pos).get(key, DEFAULT_VALUE);
return o == DEFAULT_VALUE ? Optional.empty() : Optional.of((V) o);
} | @return an updated map that does not contain {@code key} | get | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public V get(long key, V defaultValue) {
return (V) (key < 0 ? neg : pos).get(key, defaultValue);
} | @return an updated map that does not contain {@code key} | get | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public V get(Long key, V defaultValue) {
return get((long) key, defaultValue);
} | @return an updated map that does not contain {@code key} | get | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public IntMap<V> update(Long key, UnaryOperator<V> update) {
return update((long) key, update);
} | @return an updated map that does not contain {@code key} | update | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public IntMap<V> update(long key, UnaryOperator<V> update) {
return put(key, update.apply(get(key, null)), isLinear() ? editor : new Object());
} | @return an updated map that does not contain {@code key} | update | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public IntMap<V> update(long key, UnaryOperator<V> update, Object editor) {
return put(key, update.apply(get(key, null)), editor);
} | @return an updated map that does not contain {@code key} | update | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public boolean contains(long key) {
return (key < 0 ? neg : pos).get(key, DEFAULT_VALUE) != DEFAULT_VALUE;
} | @return an updated map that does not contain {@code key} | contains | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public boolean contains(Long key) {
return contains((long) key);
} | @return an updated map that does not contain {@code key} | contains | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public OptionalLong indexOf(Long key) {
return indexOf((long) key);
} | @return an updated map that does not contain {@code key} | indexOf | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public OptionalLong indexOf(long key) {
if (key < 0) {
return neg.indexOf(key);
} else {
OptionalLong index = pos.indexOf(key);
return index.isPresent() ? OptionalLong.of(index.getAsLong() + neg.size) : index;
}
} | @return an updated map that does not contain {@code key} | indexOf | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public IEntry<Long, V> nth(long idx) {
return idx < neg.size() ? neg.nth(idx) : pos.nth(idx - neg.size());
} | @return an updated map that does not contain {@code key} | nth | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public Iterator<IEntry<Long, V>> iterator() {
return Iterators.concat(neg.iterator(), pos.iterator());
} | @return an updated map that does not contain {@code key} | iterator | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public OptionalLong floorIndex(long key) {
if (key < 0) {
long idx = neg.floorIndex(key, 0);
return idx < 0 ? OptionalLong.empty() : OptionalLong.of(idx);
} else {
long idx = pos.floorIndex(key, 0);
idx = idx >= 0 ? idx + neg.size() : neg.size() - 1;
return idx < 0 ? OptionalLong.e... | @return the entry whose key is either equal to {@code key}, or just below it. If {@code key} is less than the
minimum value in the map, returns {@code null}. | floorIndex | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public OptionalLong inclusiveFloorIndex(Long key) {
return floorIndex((long) key);
} | @return the entry whose key is either equal to {@code key}, or just below it. If {@code key} is less than the
minimum value in the map, returns {@code null}. | inclusiveFloorIndex | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
public OptionalLong ceilIndex(long key) {
if (key < 0) {
long idx = neg.ceilIndex(key, 0);
if (idx < 0 && pos.size() > 0) {
idx = neg.size();
}
return idx < 0 ? OptionalLong.empty() : OptionalLong.of(idx);
} else {
long idx = pos.ceilIndex(key, 0);
return idx < 0 ? Op... | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | ceilIndex | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public OptionalLong ceilIndex(Long key) {
return ceilIndex((long) key);
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | ceilIndex | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public long size() {
return neg.size() + pos.size();
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | size | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public boolean isLinear() {
return editor != null;
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | isLinear | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public IntMap<V> forked() {
return isLinear() ? new IntMap<V>(neg, pos, false) : this;
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | forked | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public IntMap<V> linear() {
return isLinear() ? this : new IntMap<V>(neg, pos, true);
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | linear | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public List<IntMap<V>> split(int parts) {
List<IntMap<V>> result = new List<IntMap<V>>().linear();
parts = Math.max(1, Math.min((int) size(), parts));
if (parts == 1 || size() == 0) {
return result.addLast(this).forked();
}
int estParts = (int) Math.min(parts - 1, Math.max(1, (ne... | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | split | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public boolean equals(IMap<Long, V> o, BiPredicate<V, V> valEquals) {
if (o instanceof IntMap) {
IntMap<V> m = (IntMap<V>) o;
return neg.equals(m.neg, valEquals) && pos.equals(m.pos, valEquals);
} else {
return Maps.equals(this, o, valEquals);
}
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | equals | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public boolean equals(Object obj) {
if (obj instanceof IMap) {
return equals((IMap<Long, V>) obj, Objects::equals);
} else {
return false;
}
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | equals | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
@Override
public IntMap<V> clone() {
return new IntMap<>(neg, pos, isLinear());
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | clone | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IntMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IntMap.java | MIT |
default boolean contains(V value) {
return indexOf(value).isPresent();
} | @return true, if the set contains {@code value} | contains | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default IList<V> elements() {
return Lists.from(size(), this::nth, this::iterator);
} | @return a list containing all the elements in the set | elements | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default <U> IMap<V, U> zip(Function<V, U> f) {
return Maps.from(this, f);
} | @return a map which has a corresponding value, computed by {@code f}, for each element in the set | zip | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default boolean containsAll(ISet<V> set) {
return set.elements().stream().allMatch(this::contains);
} | @return true if this set contains every element in {@code set} | containsAll | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default boolean containsAll(IMap<V, ?> map) {
return containsAll(map.keys());
} | @return true if this set contains every key in {@code map} | containsAll | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default boolean containsAny(ISet<V> set) {
if (size() < set.size()) {
return set.containsAny(this);
} else {
return set.elements().stream().anyMatch(this::contains);
}
} | @return true if this set contains any element in {@code set} | containsAny | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default boolean containsAny(IMap<V, ?> map) {
return containsAny(map.keys());
} | @return true if this set contains any key in {@code map} | containsAny | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default Iterator<V> iterator(long startIndex) {
return Iterators.range(startIndex, size(), this::nth);
} | @return an iterator representing the elements of the set | iterator | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
@Override
default Spliterator<V> spliterator() {
return Spliterators.spliterator(iterator(), size(), Spliterator.DISTINCT);
} | @return an iterator representing the elements of the set | spliterator | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default Stream<V> stream() {
return StreamSupport.stream(spliterator(), false);
} | @return a {@link java.util.stream.Stream}, representing the elements in the set | stream | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default ISet<V> union(ISet<V> set) {
return Sets.union(this, set);
} | @return a new set, representing the union with {@code set} | union | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default ISet<V> difference(ISet<V> set) {
return Sets.difference(this, set);
} | @return a new set, representing the difference with {@code set} | difference | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default ISet<V> intersection(ISet<V> set) {
ISet<V> result = Sets.intersection(new Set(valueHash(), valueEquality()).linear(), this, set);
return isLinear() ? result : result.forked();
} | @return a new set, representing the intersection with {@code set} | intersection | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default java.util.Set<V> toSet() {
return Sets.toSet(elements(), this::contains);
} | @return the collection, represented as a normal Java set, which will throw {@link UnsupportedOperationException}
on writes | toSet | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default Object[] toArray() {
Object[] ary = new Object[(int) size()];
IList<V> es = elements();
IntStream.range(0, ary.length).forEach(i -> ary[i] = es.nth(i));
return ary;
} | @return the elements of the list, in an array | toArray | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default V[] toArray(IntFunction<V[]> allocator) {
V[] ary = allocator.apply((int) size());
IList<V> es = elements();
IntStream.range(0, ary.length).forEach(i -> ary[i] = es.nth(i));
return ary;
} | @param allocator a function which creates an array of the specified size
@return the elements of the list, in a typed array | toArray | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
@Override
default boolean isLinear() {
return false;
} | @return true, if the set is linear | isLinear | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
@Override
default ISet<V> forked() {
return this;
} | @return true, if the set is linear | forked | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default ISet<V> sliceIndices(long startIndex, long endIndex) {
return Sets.from(elements().slice(startIndex, endIndex), x -> {
long idx = indexOf(x).orElse(-1);
return idx < startIndex || idx >= endIndex ? OptionalLong.empty() : OptionalLong.of(idx - startIndex);
});
} | @return true, if the set is linear | sliceIndices | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
@Override
default IList<? extends ISet<V>> split(int parts) {
// TODO: do an actual slice here
parts = Math.max(1, Math.min((int) size(), parts));
return elements().split(parts).stream().map(LinearSet::from).collect(Lists.collector());
} | @return true, if the set is linear | split | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
@Override
default boolean test(V v) {
return contains(v);
} | @return true, if the set is linear | test | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISet.java | MIT |
default ISortedMap<K, V> slice(K min, K max) {
return slice(min, Bound.INCLUSIVE, max, Bound.EXCLUSIVE);
} | @param min the inclusive minimum key value
@param max the exclusive maximum key value
@return a map representing all entries within {@code [min, max)} | slice | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default ISortedMap<K, V> slice(K min, Bound minBound, K max, Bound maxBound) {
OptionalLong start = keys().ceilIndex(min, minBound);
OptionalLong end = keys().floorIndex(max, maxBound);
return start.isPresent() && end.isPresent()
? sliceIndices(start.getAsLong(), end.getAsLong() + 1)
... | @param min the inclusive minimum key value
@param max the exclusive maximum key value
@return a map representing all entries within {@code [min, max)} | slice | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default ISortedMap<K, V> sliceIndices(long startIndex, long endIndex) {
return keys().sliceIndices(startIndex, endIndex).zip(this);
} | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | sliceIndices | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
@Override
default ToLongFunction<K> keyHash() {
throw new UnsupportedOperationException("ISortedMap does not use hashes");
} | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | keyHash | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
@Override
default BiPredicate<K, K> keyEquality() {
return (a, b) -> comparator().compare(a, b) == 0;
} | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | keyEquality | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
@Override
default ISortedSet<K> keys() {
return Sets.from(Lists.lazyMap(this.entries(), IEntry::key), comparator(), this::inclusiveFloorIndex);
} | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | keys | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
@Override
default OptionalLong indexOf(K key) {
OptionalLong idx = inclusiveFloorIndex(key);
return idx.isPresent() && comparator().compare(key, nth(idx.getAsLong()).key()) == 0
? idx
: OptionalLong.empty();
} | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | indexOf | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default IEntry<K, V> floor(K key) {
return floor(key, Bound.INCLUSIVE);
} | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | floor | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default IEntry<K, V> floor(K key, Bound bound) {
OptionalLong idx = floorIndex(key, bound);
return idx.isPresent()
? nth(idx.getAsLong())
: null;
} | @return the entry whose key is either equal to {@code key}, or just below it. If {@code key} is less than the
minimum value in the map, returns {@code null}. | floor | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default IEntry<K, V> ceil(K key) {
return ceil(key, Bound.INCLUSIVE);
} | @return the entry whose key is either equal to {@code key}, or just below it. If {@code key} is less than the
minimum value in the map, returns {@code null}. | ceil | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default IEntry<K, V> ceil(K key, Bound bound) {
OptionalLong idx = ceilIndex(key, bound);
return idx.isPresent()
? nth(idx.getAsLong())
: null;
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | ceil | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default ISortedMap<K, V> merge(IMap<K, V> b, BinaryOperator<V> mergeFn) {
ISortedMap<K, V> result = forked().linear();
b.forEach(e -> result.put(e.key(), e.value(), mergeFn));
return isLinear() ? result : result.forked();
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | merge | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default ISortedMap<K, V> difference(ISet<K> keys) {
ISortedMap<K, V> result = forked().linear();
keys.forEach(result::remove);
return isLinear() ? result : result.forked();
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | difference | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default ISortedMap<K, V> intersection(ISet<K> keys) {
SortedMap<K, V> result = (SortedMap<K, V>) Maps.intersection(new SortedMap<K, V>().linear(), this, keys);
return isLinear() ? result : result.forked();
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | intersection | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default ISortedMap<K, V> union(IMap<K, V> m) {
return merge(m, Maps.MERGE_LAST_WRITE_WINS);
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | union | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default ISortedMap<K, V> difference(IMap<K, ?> m) {
return difference(m.keys());
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | difference | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default ISortedMap<K, V> update(K key, UnaryOperator<V> update) {
return this.put(key, update.apply(this.get(key, null)));
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | update | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default ISortedMap<K, V> put(K key, V value) {
return put(key, value, Maps.MERGE_LAST_WRITE_WINS);
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | put | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default ISortedMap<K, V> forked() {
return this;
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | forked | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default IEntry<K, V> first() {
return nth(0);
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | first | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
default IEntry<K, V> last() {
return nth(size() - 1);
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | last | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedMap.java | MIT |
@Override
default ToLongFunction<V> valueHash() {
throw new UnsupportedOperationException("ISortedSet does not use hashes");
} | @return the entry whose key is either equal to {@code key}, or just below it. If {@code key} is less than the
minimum value in the map, returns {@code null}. | valueHash | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
@Override
default BiPredicate<V, V> valueEquality() {
return (a, b) -> comparator().compare(a, b) == 0;
} | @return the entry whose key is either equal to {@code key}, or just below it. If {@code key} is less than the
minimum value in the map, returns {@code null}. | valueEquality | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
default OptionalLong floorIndex(V val, Bound bound) {
OptionalLong oIdx = inclusiveFloorIndex(val);
if (bound == Bound.INCLUSIVE) {
return oIdx;
} else {
if (oIdx.isPresent()) {
long idx = oIdx.getAsLong();
if (comparator().compare(nth(idx)... | @return the entry whose key is either equal to {@code key}, or just below it. If {@code key} is less than the
minimum value in the map, returns {@code null}. | floorIndex | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
default OptionalLong ceilIndex(V val, Bound bound) {
OptionalLong oIdx = inclusiveFloorIndex(val);
if (oIdx.isPresent()) {
long idx = oIdx.getAsLong();
if (bound == Bound.INCLUSIVE && comparator().compare(nth(idx), val) == 0) {
return oIdx;
} else if (... | @return the entry whose key is either equal to {@code key}, or just below it. If {@code key} is less than the
minimum value in the map, returns {@code null}. | ceilIndex | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
default OptionalLong ceilIndex(V val) {
return ceilIndex(val, Bound.INCLUSIVE);
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | ceilIndex | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
default OptionalLong floorIndex(V val) {
return floorIndex(val, Bound.INCLUSIVE);
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | floorIndex | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
@Override
default OptionalLong indexOf(V element) {
OptionalLong idx = floorIndex(element);
return idx.isPresent() && comparator().compare(nth(idx.getAsLong()), element) == 0
? idx
: OptionalLong.empty();
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | indexOf | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
default V floor(V val) {
OptionalLong idx = floorIndex(val);
return idx.isPresent()
? nth(idx.getAsLong())
: null;
} | @return the entry whose key is either equal to {@code key}, or just below it. If {@code key} is less than the
minimum value in the map, returns {@code null}. | floor | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
default V ceil(V val) {
OptionalLong idx = ceilIndex(val);
return idx.isPresent()
? nth(idx.getAsLong())
: null;
} | @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
maximum value in the map, returns {@code null}. | ceil | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
default ISortedSet<V> sliceIndices(long startIndex, long endIndex) {
long min = Math.max(0, startIndex);
long max = Math.min(size(), endIndex);
return Sets.from(elements().slice(startIndex, endIndex),
comparator(),
x -> {
long idx = indexOf(x).... | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | sliceIndices | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
@Override
default <U> ISortedMap<V, U> zip(Function<V, U> f) {
return Maps.from(this, f);
} | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | zip | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
default ISortedSet<V> union(ISet<V> s) {
return (ISortedSet<V>) Sets.union(this, s);
} | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | union | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
default ISortedSet<V> difference(ISet<V> s) {
return (ISortedSet<V>) Sets.difference(this, s);
} | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | difference | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
default ISortedSet<V> intersection(ISet<V> s) {
return (ISortedSet<V>) Sets.intersection(new SortedSet<>(), this, s);
} | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | intersection | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
default ISortedSet<V> forked() {
return this;
} | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | forked | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
default V first() {
return nth(0);
} | @param startIndex The inclusive starting index
@param endIndex The exclusive ending index
@return a sorted map representing all entries within {@code [startIndex, endIndex)} | first | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ISortedSet.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ISortedSet.java | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.