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 OptionalLong indexOf(double key) {
return map.indexOf(doubleToLong(key));
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | indexOf | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public OptionalLong indexOf(Double key) {
return indexOf((double) key);
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | indexOf | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public IEntry<Double, V> nth(long idx) {
return convertEntry(map.nth(idx));
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | nth | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public long size() {
return map.size();
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | size | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public OptionalLong floorIndex(double key) {
return map.floorIndex(doubleToLong(key));
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | floorIndex | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public OptionalLong inclusiveFloorIndex(Double key) {
return floorIndex((double) key);
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | inclusiveFloorIndex | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public OptionalLong ceilIndex(double key) {
return map.ceilIndex(doubleToLong(key));
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | ceilIndex | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public OptionalLong ceilIndex(Double key) {
return ceilIndex((double) key);
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | ceilIndex | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public FloatMap<V> slice(double min, Bound minBound, double max, Bound maxBound) {
return new FloatMap<>(map.slice(doubleToLong(min), minBound, doubleToLong(max), maxBound));
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | slice | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public FloatMap<V> slice(double min, double max) {
return slice(min, Bound.INCLUSIVE, max, Bound.EXCLUSIVE);
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | slice | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public FloatMap<V> slice(Double min, Double max) {
return slice((double) min, (double) max);
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | slice | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public FloatMap<V> merge(IMap<Double, V> b, BinaryOperator<V> mergeFn) {
if (b instanceof FloatMap) {
FloatMap<V> m = (FloatMap<V>) b;
return new FloatMap<>(map.merge(m.map, mergeFn));
} else {
return (FloatMap<V>) Maps.merge(this.clone(), b, mergeFn);
}
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | merge | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public FloatMap<V> difference(ISet<Double> keys) {
return (FloatMap<V>) Maps.difference(this, keys);
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | difference | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public FloatMap<V> intersection(ISet<Double> keys) {
return this.intersection(Maps.from(keys, n -> null));
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | intersection | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public FloatMap<V> union(IMap<Double, V> m) {
return this.merge(m, (BinaryOperator<V>) Maps.MERGE_LAST_WRITE_WINS);
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | union | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public FloatMap<V> difference(IMap<Double, ?> b) {
if (b instanceof FloatMap) {
FloatMap<V> m = (FloatMap<V>) b;
return new FloatMap<>(map.difference(m.map));
} else {
return (FloatMap<V>) Maps.difference(this.clone(), b.keys());
}
} | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | difference | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public FloatMap<V> intersection(IMap<Double, ?> b) {
if (b instanceof FloatMap) {
FloatMap<V> m = (FloatMap<V>) b;
return new FloatMap<>(map.intersection(m.map));
} else {
FloatMap<V> result = (FloatMap<V>) Maps.intersection(new FloatMap<V>().linear(), this, b.keys());
return... | @param list a list of {@link IEntry} objects
@return an {@link IntMap} representing the entries in the list | intersection | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public FloatMap<V> remove(double key) {
return remove(key, isLinear() ? map.editor : new Object());
} | @return an updated map that does not contain {@code key} | remove | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public FloatMap<V> remove(double key, Object editor) {
IntMap<V> mapPrime = map.remove(doubleToLong(key), editor);
if (isLinear()) {
map = mapPrime;
return this;
} else {
return new FloatMap<>(mapPrime);
}
} | @return an updated map that does not contain {@code key} | remove | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public FloatMap<V> remove(Double key) {
return remove((double) key);
} | @return an updated map that does not contain {@code key} | remove | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public <U> FloatMap<U> mapValues(BiFunction<Double, V, U> f) {
return new FloatMap<>(map.mapValues((k, v) -> f.apply(longToDouble(k), v)));
} | @return an updated map that does not contain {@code key} | mapValues | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public Optional<V> get(double key) {
return map.get(doubleToLong(key));
} | @return an updated map that does not contain {@code key} | get | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public V get(double key, V defaultValue) {
return map.get(doubleToLong(key), defaultValue);
} | @return an updated map that does not contain {@code key} | get | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public V get(Double key, V defaultValue) {
return get((double) key, defaultValue);
} | @return an updated map that does not contain {@code key} | get | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public FloatMap<V> update(Double key, UnaryOperator<V> update) {
return update((double) key, update);
} | @return an updated map that does not contain {@code key} | update | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public FloatMap<V> update(double key, UnaryOperator<V> update) {
return put(key, update.apply(get(key, null)), isLinear() ? isLinear() : new Object());
} | @return an updated map that does not contain {@code key} | update | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public FloatMap<V> update(double 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/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public List<FloatMap<V>> split(int parts) {
return map.split(parts).stream().map(m -> new FloatMap<>(m)).collect(Lists.collector());
} | @return an updated map that does not contain {@code key} | split | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public boolean isLinear() {
return map.isLinear();
} | @return an updated map that does not contain {@code key} | isLinear | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public FloatMap<V> forked() {
return isLinear() ? new FloatMap<>(map.forked()) : this;
} | @return an updated map that does not contain {@code key} | forked | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public FloatMap<V> linear() {
return isLinear() ? this : new FloatMap<>(map.linear());
} | @return an updated map that does not contain {@code key} | linear | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public FloatMap<V> clone() {
return new FloatMap<>(map.clone());
} | @return an updated map that does not contain {@code key} | clone | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public boolean equals(IMap<Double, V> o, BiPredicate<V, V> valEquals) {
if (o instanceof FloatMap) {
FloatMap<V> m = (FloatMap<V>) o;
return map.equals(m.map, valEquals);
} else {
return Maps.equals(this, o, valEquals);
}
} | @return an updated map that does not contain {@code key} | equals | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
@Override
public boolean equals(Object obj) {
if (obj instanceof IMap) {
return equals((IMap<Double, V>) obj, Objects::equals);
} else {
return false;
}
} | @return an updated map that does not contain {@code key} | equals | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
private static <V> IEntry<Double, V> convertEntry(IEntry<Long, V> e) {
return e != null ? IEntry.of(longToDouble(e.key()), e.value()) : null;
} | @return an updated map that does not contain {@code key} | convertEntry | java | lacuna/bifurcan | src/io/lacuna/bifurcan/FloatMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/FloatMap.java | MIT |
public static <V, E> Optional<IList<V>> shortestPath(
IGraph<V, E> graph,
V start,
Predicate<V> accept,
ToDoubleFunction<IEdge<V, E>> cost
) {
return shortestPath(graph, LinearList.of(start), accept, cost);
} | @param graph a graph
@param start the starting vertex
@param accept a predicate for whether a vertex represents a search end state
@param cost the cost associated with each edge
@return the shortest path, if one exists, between the starting vertex and an accepted vertex, excluding trivial
solutions where a starting... | shortestPath | java | lacuna/bifurcan | src/io/lacuna/bifurcan/Graphs.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Graphs.java | MIT |
public static <V, E> Optional<IList<V>> shortestPath(
IGraph<V, E> graph,
Iterable<V> start,
Predicate<V> accept,
ToDoubleFunction<IEdge<V, E>> cost
) {
IMap<V, IMap<V, ShortestPathState<V>>> originStates = new LinearMap<>();
PriorityQueue<ShortestPathState<V>> queue = new PriorityQueu... | @param graph a graph
@param start a list of starting vertices
@param accept a predicate for whether a vertex represents a search end state
@param cost the cost associated with each edge
@return the shortest path, if one exists, between a starting vertex and an accepted vertex, excluding trivial
solutions where a st... | shortestPath | java | lacuna/bifurcan | src/io/lacuna/bifurcan/Graphs.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Graphs.java | MIT |
public static <V> Set<Set<V>> connectedComponents(IGraph<V, ?> graph) {
if (graph.isDirected()) {
throw new IllegalArgumentException("graph must be undirected");
}
LinearSet<V> traversed = new LinearSet<>((int) graph.vertices().size(), graph.vertexHash(), graph.vertexEquality());
Set<Set<V>> resu... | @return sets of vertices, where each vertex can reach every other vertex within the set | connectedComponents | java | lacuna/bifurcan | src/io/lacuna/bifurcan/Graphs.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Graphs.java | MIT |
public static <V> Set<Set<V>> biconnectedComponents(IGraph<V, ?> graph) {
Set<V> cuts = articulationPoints(graph);
Set<Set<V>> result = new Set<Set<V>>().linear();
for (Set<V> component : connectedComponents(graph.select(graph.vertices().difference(cuts)))) {
result.add(
component.union(
... | @return sets of vertices, where each vertex can reach every other vertex within the set, even if a single vertex
is removed | biconnectedComponents | java | lacuna/bifurcan | src/io/lacuna/bifurcan/Graphs.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Graphs.java | MIT |
public static <V> Set<V> articulationPoints(IGraph<V, ?> graph) {
if (graph.isDirected()) {
throw new IllegalArgumentException("graph must be undirected");
}
// algorithmic state
IMap<V, ArticulationPointState<V>> state = new LinearMap<>(
(int) graph.vertices().size(),
graph.verte... | @return all articulation or "cut" vertices, where the removal of that vertex will partition the graph | articulationPoints | java | lacuna/bifurcan | src/io/lacuna/bifurcan/Graphs.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Graphs.java | MIT |
public static <V, E> List<List<V>> cycles(IGraph<V, E> graph) {
if (!graph.isDirected()) {
throw new IllegalArgumentException("graph must be directed");
}
// traversal
LinearList<V> path = new LinearList<>();
IList<Iterator<V>> branches = new LinearList<>();
//state
LinearSet<V> blo... | @param graph a directed graph
@return a list of all cyclical paths through the graph | cycles | java | lacuna/bifurcan | src/io/lacuna/bifurcan/Graphs.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Graphs.java | MIT |
public static <V> Iterable<V> bfsVertices(V start, Function<V, Iterable<V>> adjacent) {
return bfsVertices(LinearList.of(start), adjacent);
} | @param graph a directed graph
@return a list of all cyclical paths through the graph | bfsVertices | java | lacuna/bifurcan | src/io/lacuna/bifurcan/Graphs.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Graphs.java | MIT |
public static <V> Iterable<V> bfsVertices(Iterable<V> start, Function<V, Iterable<V>> adjacent) {
LinearList<V> queue = new LinearList<>();
ISet<V> traversed = new LinearSet<>();
start.forEach(queue::addLast);
return () -> Iterators.from(
() -> queue.size() > 0,
() -> {
V v =... | @param graph a directed graph
@return a list of all cyclical paths through the graph | bfsVertices | java | lacuna/bifurcan | src/io/lacuna/bifurcan/Graphs.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Graphs.java | MIT |
default V nth(long idx, V defaultValue) {
if (idx < 0 || idx >= size()) {
return defaultValue;
}
return nth(idx);
} | @return the element at {@code idx}, or {@code defaultValue} if it is not within {@code [0, size-1]} | nth | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ICollection.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ICollection.java | MIT |
default Iterator<V> iterator() {
return iterator(0);
} | @return the element at {@code idx}, or {@code defaultValue} if it is not within {@code [0, size-1]} | iterator | java | lacuna/bifurcan | src/io/lacuna/bifurcan/ICollection.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/ICollection.java | MIT |
default OptionalLong indexOf(V vertex) {
return vertices().indexOf(vertex);
} | @return the index of {@code vertex}, if it's present | indexOf | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IGraph.java | MIT |
default V nth(long idx) {
return vertices().nth(idx);
} | @return the index of {@code vertex}, if it's present | nth | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IGraph.java | MIT |
default Iterator<V> iterator(long startIndex) {
return vertices().iterator(startIndex);
} | @return the index of {@code vertex}, if it's present | iterator | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IGraph.java | MIT |
default long size() {
return vertices().size();
} | @return the index of {@code vertex}, if it's present | size | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IGraph.java | MIT |
default IList<? extends IGraph<V, E>> split(int parts) {
return List.of(this);
} | @return a singleton list of the graph, unsplit. The graph can be split into separate pieces in linear time
using {@link Graphs#connectedComponents(IGraph)}. | split | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IGraph.java | MIT |
default IGraph<V, E> add(IEdge<V, E> edge) {
return link(edge.from(), edge.to(), edge.value());
} | @return a singleton list of the graph, unsplit. The graph can be split into separate pieces in linear time
using {@link Graphs#connectedComponents(IGraph)}. | add | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IGraph.java | MIT |
default IGraph<V, E> remove(IEdge<V, E> edge) {
return unlink(edge.from(), edge.to());
} | @return a singleton list of the graph, unsplit. The graph can be split into separate pieces in linear time
using {@link Graphs#connectedComponents(IGraph)}. | remove | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IGraph.java | MIT |
default IGraph<V, E> link(V from, V to, E edge) {
return link(from, to, edge, (BinaryOperator<E>) MERGE_LAST_WRITE_WINS);
} | @return a singleton list of the graph, unsplit. The graph can be split into separate pieces in linear time
using {@link Graphs#connectedComponents(IGraph)}. | link | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IGraph.java | MIT |
default IGraph<V, E> link(V from, V to) {
return link(from, to, null, (BinaryOperator<E>) MERGE_LAST_WRITE_WINS);
} | @return a singleton list of the graph, unsplit. The graph can be split into separate pieces in linear time
using {@link Graphs#connectedComponents(IGraph)}. | link | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IGraph.java | MIT |
default IGraph<V, E> merge(IGraph<V, E> graph, BinaryOperator<E> merge) {
return Graphs.merge(this, graph, merge);
} | @return a singleton list of the graph, unsplit. The graph can be split into separate pieces in linear time
using {@link Graphs#connectedComponents(IGraph)}. | merge | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IGraph.java | MIT |
default IGraph<V, E> merge(IGraph<V, E> graph) {
return merge(graph, (BinaryOperator<E>) MERGE_LAST_WRITE_WINS);
} | @return a singleton list of the graph, unsplit. The graph can be split into separate pieces in linear time
using {@link Graphs#connectedComponents(IGraph)}. | merge | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IGraph.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IGraph.java | MIT |
default boolean isLinear() {
return false;
} | @return true, if the list is linear | isLinear | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
default Stream<V> stream() {
return StreamSupport.stream(spliterator(), false);
} | @return a {@link java.util.stream.Stream}, representing the elements in the list | stream | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
@Override
default Spliterator<V> spliterator() {
return Spliterators.spliterator(iterator(), size(), Spliterator.ORDERED);
} | @return a {@link java.util.stream.Stream}, representing the elements in the list | spliterator | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
default Iterator<V> iterator(long startIndex) {
return Lists.iterator(this, startIndex);
} | @return a {@link java.util.stream.Stream}, representing the elements in the list | iterator | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
default Object[] toArray() {
Object[] ary = new Object[(int) size()];
IntStream.range(0, ary.length).forEach(i -> ary[i] = nth(i));
return ary;
} | @return the elements of the list, in an array | toArray | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
default V[] toArray(IntFunction<V[]> allocator) {
V[] ary = allocator.apply((int) size());
for (int i = 0; i < ary.length; i++) {
ary[i] = 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/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
default java.util.List<V> toList() {
return Lists.toList(this);
} | @return the collection, represented as a normal Java list, which will throw an
{@link UnsupportedOperationException} for any write | toList | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
@Override
default IList<IList<V>> split(int parts) {
parts = Math.max(1, Math.min((int) size(), parts));
IList<V>[] ary = new IList[parts];
long subSize = size() / parts;
long offset = 0;
for (int i = 0; i < parts; i++) {
ary[i] = Lists.slice(this, offset, i == (parts - 1) ? size() : offset... | @return the collection, represented as a normal Java list, which will throw an
{@link UnsupportedOperationException} for any write | split | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
default IList<V> slice(long start, long end) {
return Lists.slice(this, start, end);
} | @param start the inclusive start of the range
@param end the exclusive end of the range
@return a sub-range of the list within {@code [start, end)}, which is linear if {@code this} is linear | slice | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
default IList<V> concat(IList<V> l) {
return Lists.concat(this, l);
} | @param l another list
@return a new collection representing the concatenation of the two lists, which is linear if {@code this} is linear | concat | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
default V first() {
if (size() == 0) {
throw new IndexOutOfBoundsException();
}
return nth(0);
} | @return the first element
@throws IndexOutOfBoundsException if the collection is empty | first | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
default V last() {
if (size() == 0) {
throw new IndexOutOfBoundsException();
}
return nth(size() - 1);
} | @return the last element
@throws IndexOutOfBoundsException if the collection is empty | last | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
@Override
default IList<V> forked() {
return this;
} | @return the last element
@throws IndexOutOfBoundsException if the collection is empty | forked | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
default boolean equals(Object o, BiPredicate<V, V> equals) {
if (o instanceof IList) {
return Lists.equals(this, (IList<V>) o, equals);
}
return false;
} | @return the last element
@throws IndexOutOfBoundsException if the collection is empty | equals | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IList.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IList.java | MIT |
default V get(K key, V defaultValue) {
OptionalLong idx = indexOf(key);
return idx.isPresent()
? nth(idx.getAsLong()).value()
: defaultValue;
} | @return the value under {@code key}, or {@code defaultValue} if there is no such key | get | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default Optional<V> get(K key) {
return Optional.ofNullable(get(key, null));
} | @return an {@link Optional} containing the value under {@code key}, or nothing if the value is {@code null} or
is not contained within the map. | get | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default V getOrCreate(K key, Supplier<V> f) {
V val = get(key, null);
if (val == null) {
val = f.get();
put(key, val);
}
return val;
} | @return the value under {@code key}, or one generated by {@code f} if there is no such key | getOrCreate | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default boolean contains(K key) {
return indexOf(key).isPresent();
} | @return true if {@code key} is in the map, false otherwise | contains | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default IList<IEntry<K, V>> entries() {
return Lists.from(size(), this::nth, this::iterator);
} | @return a list containing all the entries within the map | entries | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default ISet<K> keys() {
return Sets.from(Lists.lazyMap(entries(), IEntry::key), this::indexOf);
} | @return a set representing all keys in the map | keys | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default IList<V> values() {
return Lists.lazyMap(entries(), IEntry::value);
} | @return a list representing all values in the map | values | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default <U> IMap<K, U> mapValues(BiFunction<K, V, U> f) {
Map<K, U> m = new Map<K, U>(keyHash(), keyEquality()).linear();
this.forEach(e -> m.put(e.key(), f.apply(e.key(), e.value())));
return isLinear() ? m : m.forked();
} | @param f a function which transforms the values
@param <U> the new type of the values
@return a transformed map which shares the same equality semantics | mapValues | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default boolean containsAll(ISet<K> set) {
return set.elements().stream().allMatch(this::contains);
} | @return true if this map contains all elements in {@code set} | containsAll | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default boolean containsAll(IMap<K, ?> map) {
return containsAll(map.keys());
} | @return true if this map contains all keys in {@code map} | containsAll | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default boolean containsAny(ISet<K> set) {
return set.elements().stream().anyMatch(this::contains);
} | @return true if this map contains any element in {@code set} | containsAny | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default boolean containsAny(IMap<K, ?> map) {
return containsAny(map.keys());
} | @return true if this map contains any element in {@code map} | containsAny | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default boolean isLinear() {
return false;
} | @return true, if the collection is linear | isLinear | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default java.util.Map<K, V> toMap() {
return Maps.toMap(this);
} | @return the collection, represented as a normal Java map, which will throw {@link UnsupportedOperationException}
on writes | toMap | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default Iterator<IEntry<K, V>> iterator(long startIndex) {
return Iterators.range(startIndex, size(), this::nth);
} | @return an iterator over all entries in the map | iterator | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default Stream<IEntry<K, V>> stream() {
return StreamSupport.stream(spliterator(), false);
} | @return a {@link java.util.stream.Stream}, representing the entries in the map | stream | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
@Override
default Spliterator<IEntry<K, V>> spliterator() {
return Spliterators.spliterator(iterator(), size(), Spliterator.DISTINCT);
} | @return a {@link java.util.stream.Stream}, representing the entries in the map | spliterator | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default IMap<K, V> merge(IMap<K, V> b, BinaryOperator<V> mergeFn) {
return Maps.merge(this, b, mergeFn);
} | @param b another map
@param mergeFn a function which, in the case of key collisions, takes two values and returns the merged result
@return a new map representing the merger of the two maps | merge | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default IMap<K, V> difference(ISet<K> keys) {
return Maps.difference(this, keys);
} | @return a new map representing the current map, less the keys in {@code keys} | difference | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default IMap<K, V> intersection(ISet<K> keys) {
IMap<K, V> result = Maps.intersection(new Map<K, V>(keyHash(), keyEquality()).linear(), this, keys);
return isLinear() ? result : result.forked();
} | @return a new map representing the current map, but only with the keys in {@code keys} | intersection | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default IMap<K, V> union(IMap<K, V> m) {
return merge(m, Maps.MERGE_LAST_WRITE_WINS);
} | @return a combined map, with the values from {@code m} shadowing those in this amp | union | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default IMap<K, V> difference(IMap<K, ?> m) {
return difference(m.keys());
} | @return a new map representing the current map, less the keys in {@code m} | difference | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default IMap<K, V> intersection(IMap<K, ?> m) {
return intersection(m.keys());
} | @return a new map representing the current map, but only with the keys in {@code m} | intersection | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default IMap<K, V> update(K key, UnaryOperator<V> update) {
return this.put(key, update.apply(this.get(key, null)));
} | @param update a function which takes the existing value, or {@code null} if none exists, and returns an updated
value.
@return an updated map with {@code update(value)} under {@code key}. | update | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default IMap<K, V> put(K key, V value) {
return put(key, value, Maps.MERGE_LAST_WRITE_WINS);
} | @return an updated map with {@code value} stored under {@code key} | put | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
@Override
default IMap<K, V> forked() {
return this;
} | @return an updated map that does not contain {@code key} | forked | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default IMap<K, V> sliceIndices(long startIndex, long endIndex) {
return Maps.from(keys().sliceIndices(startIndex, endIndex), this::apply);
} | @return an updated map that does not contain {@code key} | sliceIndices | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
@Override
default IList<? extends IMap<K, V>> split(int parts) {
return keys()
.split(parts)
.stream()
.map(ks -> ks.zip(this))
.collect(Lists.collector());
} | @return an updated map that does not contain {@code key} | split | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
default boolean equals(IMap<K, V> m, BiPredicate<V, V> equals) {
return Maps.equals(this, m, equals);
} | @param m another map
@param equals a predicate which checks value equalities
@return true, if the maps are equivalent | equals | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
@Override
default V apply(K k) {
V defaultVal = (V) new Object();
V val = get(k, defaultVal);
if (val == defaultVal) {
throw new IllegalArgumentException("key not found");
}
return val;
} | @return the corresponding value
@throws IllegalArgumentException if no such key is inside the map | apply | java | lacuna/bifurcan | src/io/lacuna/bifurcan/IMap.java | https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/IMap.java | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.