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
private boolean isNode(int mask) { return (nodemap & mask) != 0; }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
isNode
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public boolean contains(int hash, K key, BiPredicate<K, K> equals) { return get(hash, key, equals, DEFAULT_VALUE) != DEFAULT_VALUE; }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
contains
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public Object get(int hash, K key, BiPredicate<K, K> equals, Object defaultValue) { if (hash != this.hash) { return defaultValue; } int idx = indexOf(key, equals); if (idx < 0) { return defaultValue; } else { return entries[idx + 1]; } }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
get
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
@Override public int hash(int idx) { return hash; }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
hash
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
@Override public IEntry<K, V> nth(long idx) { int i = (int) idx << 1; return IEntry.of((K) entries[i], (V) entries[i + 1]); }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
nth
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
@Override public long indexOf(int shift, int hash, K key, BiPredicate<K, K> equals) { if (this.hash == hash) { for (int i = 0; i < entries.length; i += 2) { if (equals.test(key, (K) entries[i])) { return i >> 1; } } } return -1; }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
indexOf
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
@Override public INode<K, V> put( int shift, Object editor, int hash, K key, V value, BiPredicate<K, K> equals, BinaryOperator<V> merge ) { if (hash != this.hash) { return new Node<K, V>(editor) .putNode(hashMask(this.hash, shift)...
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
put
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
@Override public INode<K, V> remove(int shift, Object editor, int hash, K key, BiPredicate<K, K> equals) { if (hash != this.hash) { return this; } else { int idx = indexOf(key, equals); return idx < 0 ? this : new Collision<K, V>(hash, ArrayVector.remove(entries, idx, 2)); ...
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
remove
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public <U> Collision<K, U> mapVals(Object editor, BiFunction<K, V, U> f) { Collision c = new Collision(hash, entries.clone()); for (int i = 0; i < entries.length; i += 2) { c.entries[i + 1] = f.apply((K) c.entries[i], (V) c.entries[i + 1]); } return c; }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
mapVals
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public Iterable<IEntry<K, V>> entries() { return () -> Iterators.range( entries.length >> 1, i -> { int idx = (int) (i << 1); return IEntry.of((K) entries[idx], (V) entries[idx + 1]); } ); }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
entries
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public long size() { return entries.length >> 1; }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
size
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
@Override public boolean equals(INode<K, V> o, BiPredicate<K, K> keyEquals, BiPredicate<V, V> valEquals) { if (this == o) { return true; } if (o instanceof Collision) { Collision<K, V> c = (Collision<K, V>) o; if (c.size() == size()) { Iterator<IEntry<K, V>> it...
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
equals
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
private int indexOf(K key, BiPredicate<K, K> equals) { for (int i = 0; i < entries.length; i += 2) { if (equals.test(key, (K) entries[i])) { return i; } } return -1; }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
indexOf
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
private static int hashMask(int hash, int shift) { return 1 << ((hash >>> shift) & 31); }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
hashMask
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public static <K, V> boolean contains(Node<K, V> node, int shift, int hash, K key, BiPredicate<K, K> equals) { return get(node, shift, hash, key, equals, DEFAULT_VALUE) != DEFAULT_VALUE; }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
contains
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public static <K, V> Object get( Node<K, V> node, int shift, int hash, K key, BiPredicate<K, K> equals, Object defaultValue ) { Object currNode = node; while (!(currNode instanceof Collision)) { Node<K, V> n = (Node<K, V>) currNode; int mask = hashMask(hash, s...
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
get
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public static <K, V> INode<K, V> mergeNodes( int shift, Object editor, INode<K, V> a, INode<K, V> b, BiPredicate<K, K> equals, BinaryOperator<V> merge ) { Collision<K, V> ca, cb; Node<K, V> na, nb; // Node / Node if (a instanceof Node && b instanceof Node) { ...
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
mergeNodes
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public static <K, V> Node<K, V> merge( int shift, Object editor, Node<K, V> a, Node<K, V> b, BiPredicate<K, K> equals, BinaryOperator<V> merge ) { Node<K, V> result = new Node<K, V>(editor); PrimitiveIterator.OfInt masks = Util.masks(a.datamap | a.nodemap | b.datamap | b.n...
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
merge
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public static <K, V> INode<K, V> diffNodes( int shift, Object editor, INode<K, V> a, INode<K, V> b, BiPredicate<K, K> equals ) { Collision<K, V> ca, cb; Node<K, V> na, nb; // Node / Node if (a instanceof Node && b instanceof Node) { return difference(shift, editor,...
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
diffNodes
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public static <K, V> Node<K, V> difference( int shift, Object editor, Node<K, V> a, Node<K, V> b, BiPredicate<K, K> equals ) { Node<K, V> result = new Node<K, V>(editor); INode<K, V> n; int idx; PrimitiveIterator.OfInt masks = Util.masks(a.nodemap | a.datamap); while...
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
difference
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public static <K, V> INode<K, V> intersectNodes( int shift, Object editor, INode<K, V> a, INode<K, V> b, BiPredicate<K, K> equals ) { Collision<K, V> ca, cb; Node<K, V> na, nb; // Node / Node if (a instanceof Node && b instanceof Node) { return intersection(shift, ...
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
intersectNodes
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public static <K, V> Node<K, V> intersection( int shift, Object editor, Node<K, V> a, Node<K, V> b, BiPredicate<K, K> equals ) { Node<K, V> result = new Node<K, V>(editor); PrimitiveIterator.OfInt masks = Util.masks((a.nodemap | a.datamap) & (b.nodemap | b.datamap)); while (...
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
intersection
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public static <K, V> IList<Node<K, V>> split(Object editor, Node<K, V> node, int targetSize) { IList<Node<K, V>> result = new LinearList<>(); if ((node.size() >> 1) < targetSize) { result.addLast(node); } else { Node<K, V> acc = new Node<>(editor); PrimitiveIterator.OfInt masks = Util.mas...
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
split
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
private static <K, V> Node<K, V> transferNode(int mask, Node<K, V> src, Node<K, V> dst) { return dst.putNode(mask, src.node(mask)); }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
transferNode
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
private static <K, V> Node<K, V> transferEntry(int mask, Node<K, V> src, Node<K, V> dst) { int idx = src.entryIndex(mask); return dst.putEntry(mask, src.hashes[idx], (K) src.content[idx << 1], (V) src.content[(idx << 1) + 1]); }
This is an implementation based on the one described in https://michael.steindorfer.name/publications/oopsla15.pdf. <p> It adds in support for transient/linear updates, and allows for empty buffer space between the nodes and nodes to minimize allocations when a node is repeatedly updated in-place. @author ztellman
transferEntry
java
lacuna/bifurcan
src/io/lacuna/bifurcan/nodes/MapNodes.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/nodes/MapNodes.java
MIT
public static long[] create() { return BitVector.create(0); }
@return a bit-int set, with an implied size of 0.
create
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitIntSet.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitIntSet.java
MIT
public static long get(long[] set, int bitsPerElement, int idx) { return BitVector.get(set, idx * bitsPerElement, bitsPerElement); }
@param set the bit-int set @param bitsPerElement the bits per element @param idx the table @return the rowValue stored at the given table
get
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitIntSet.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitIntSet.java
MIT
public static int indexOf(long[] set, int bitsPerElement, int size, long val) { int low = 0; int high = size - 1; int mid = 0; while (low <= high) { mid = (low + high) >>> 1; long curr = get(set, bitsPerElement, mid); if (curr < val) { low = mid + 1; } else if (curr > v...
Performs a binary search for the given rowValue. @param set the bit-int set @param bitsPerElement the bits per element @param size the number of elements in the set @param val the rowValue to search for @return If idx >= 0, the actual table of the rowValue. Otherwise, the return rowVal...
indexOf
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitIntSet.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitIntSet.java
MIT
public static long[] add(long[] set, int bitsPerElement, int size, long val) { int idx = indexOf(set, bitsPerElement, size, val); if (idx < 0) { idx = -idx - 1; return BitVector.insert(set, (bitsPerElement * size), val, (bitsPerElement * idx), bitsPerElement); } else { return set; } ...
@param set the bit-int set @param bitsPerElement the bits per element @param size the number of elements in the set @param val the rowValue to add @return an updated long[] array if the rowValue is not already in the set, otherwise 'set' is returned unchanged
add
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitIntSet.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitIntSet.java
MIT
public static long[] remove(long[] set, int bitsPerElement, int size, long val) { int idx = indexOf(set, bitsPerElement, size, val); if (idx < 0) { return set; } else { return BitVector.remove(set, (bitsPerElement * size), (bitsPerElement * idx), bitsPerElement); } }
@param set the bit-int set @param bitsPerElement the bits per element @param size the number of elements in the set @param val the rowValue to remove @return an updated long[] array if the rowValue was in the set, otherwise 'set' is returned unchanged
remove
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitIntSet.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitIntSet.java
MIT
public static int bitOffset(long n) { return deBruijnIndex[0xFF & (int) ((n * 0x022fdd63cc95386dL) >>> 58)]; }
@param n a number, which must be a power of two @return the offset of the bit
bitOffset
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static long lowestBit(long n) { return n & -n; }
@param n a number @return the same number, with all but the lowest bit zeroed out
lowestBit
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static int lowestBit(int n) { return n & -n; }
@param n a number @return the same number, with all but the lowest bit zeroed out
lowestBit
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static long highestBit(long n) { return Long.highestOneBit(n); }
@param n a number @return the same number, with all but the highest bit zeroed out
highestBit
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static int highestBit(int n) { return Integer.highestOneBit(n); }
@param n a number @return the same number, with all but the highest bit zeroed out
highestBit
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static int log2Floor(long n) { return bitOffset(highestBit(n)); }
@param n a number @return the log2 of that value, rounded down
log2Floor
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static int log2Ceil(long n) { int log2 = log2Floor(n); return isPowerOfTwo(n) ? log2 : log2 + 1; }
@param n a number @return the log2 of the value, rounded up
log2Ceil
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static boolean test(int n, int offset) { return (n & (1 << offset)) != 0; }
@param n a number @param offset the offset of the bit being tested @return true if the bit is 1, false otherwise
test
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static boolean test(long n, int offset) { return (n & (1L << offset)) != 0; }
@param n a number @param offset the offset of the bit being tested @return true if the bit is 1, false otherwise
test
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static long maskBelow(int bits) { return (1L << bits) - 1; }
@param bits a bit offset @return a mask, with all bits below that offset set to one
maskBelow
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static long maskAbove(int bits) { return -1L & ~maskBelow(bits); }
@param bits a bit offset @return a mask, with all bits above that offset set to one
maskAbove
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static int branchingBit(long a, long b) { if (a == b) { return -1; } else { return bitOffset(highestBit(a ^ b)); } }
@return the offset of the highest bit which differs between {@code a} and {@code b}
branchingBit
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static boolean isPowerOfTwo(long n) { return (n & (n - 1)) == 0; }
@param n a number @return true, if the number is a power of two
isPowerOfTwo
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static long slice(long n, int start, int end) { return (n >> start) & maskBelow(end - start); }
@param n a number @return true, if the number is a power of two
slice
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Bits.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Bits.java
MIT
public static long[] create(int length) { return new long[(Math.max(0, length - 1) >> 6) + 1]; }
@param length the bit length of the vector @return a bit vector which can hold the specified number of bits
create
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitVector.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitVector.java
MIT
public static long[] clone(long[] vector) { long[] nVector = new long[vector.length]; System.arraycopy(vector, 0, nVector, 0, vector.length); return nVector; }
@param length the bit length of the vector @return a bit vector which can hold the specified number of bits
clone
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitVector.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitVector.java
MIT
public static boolean test(long[] vector, int bitIndex) { return (vector[bitIndex >> 6] & (1L << (bitIndex & 63))) != 0; }
@param vector the bit vector @param bitIndex the bit to be tested @return true if the bit is 1, false otherwise
test
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitVector.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitVector.java
MIT
public static long[] interleave(int bitLen, long[] vectors) { long[] interleaved = create(bitLen * vectors.length); int offset = (interleaved.length << 6) - 1; for (int i = 0; i < bitLen; i++) { long mask = 1L << i; for (int j = vectors.length - 1; j >= 0; j--) { long val = (vectors[j]...
@param bitLen the number of significant bits in each vector @param vectors a list of bit-vectors @return the bit-wise interleaving of the values, starting with the topmost bit of the 0th vector, followed by the topmost bit of the 1st vector, and downward from there
interleave
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitVector.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitVector.java
MIT
public static int branchingBit(long[] a, long[] b, int aIdx, int bIdx, int bitOffset, int bitLen) { long mask = maskAbove(bitOffset & 63); int branch = Bits.branchingBit(a[aIdx] & mask, b[bIdx] & mask); if (branch >= 0) { return branch; } aIdx++; bIdx++; int branchIdx = 64 - bitOffs...
@param bitLen the number of significant bits in each vector @param vectors a list of bit-vectors @return the bit-wise interleaving of the values, starting with the topmost bit of the 0th vector, followed by the topmost bit of the 1st vector, and downward from there
branchingBit
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitVector.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitVector.java
MIT
public static long get(long[] vector, int offset, int len) { int idx = offset >> 6; int bitIdx = offset & 63; int truncatedLen = Math.min(len, 64 - bitIdx); long val = (vector[idx] >>> bitIdx) & maskBelow(truncatedLen); if (len != truncatedLen) { val |= (vector[idx + 1] & maskBelow(len - tru...
Reads a bit range from the vector, which cannot be longer than 64 bits. @param vector the bit vector @param offset the bit offset @param len the bit length @return a number representing the bit range
get
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitVector.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitVector.java
MIT
public static void overwrite(long[] vector, long val, int offset, int len) { int idx = offset >> 6; int bitIdx = offset & 63; int truncatedValLen = Math.min(len, 64 - bitIdx); vector[idx] &= ~(maskBelow(truncatedValLen) << bitIdx); vector[idx] |= val << bitIdx; if (len != truncatedValLen) { ...
Overwrites a bit range within the vector. @param vector the bit vector @param val the rowValue to set @param offset the offset of the write @param len the bit length of the rowValue
overwrite
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitVector.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitVector.java
MIT
public static void overwrite(long[] vector, int bitIdx, boolean flag) { long mask = (1L << (bitIdx & 63)); if (flag) { vector[bitIdx >> 6] |= mask; } else { vector[bitIdx >> 6] &= ~mask; } }
Overwrites a bit range within the vector. @param vector the bit vector @param val the rowValue to set @param offset the offset of the write @param len the bit length of the rowValue
overwrite
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitVector.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitVector.java
MIT
public static void copy(long[] src, int srcOffset, long[] dst, int dstOffset, int len) { int srcLimit = srcOffset + len; while (srcOffset < srcLimit) { int srcIdx = srcOffset & 63; int dstIdx = dstOffset & 63; int srcRemainder = 64 - srcIdx; int dstRemainder = 64 - dstIdx; int ...
Copies a bit range from one vector to another. @param src the source vector @param srcOffset the bit offset within src @param dst the destination vector @param dstOffset the bit offset within dst @param len the length of the bit range
copy
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitVector.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitVector.java
MIT
public static long[] interpose(long[] vector, int vectorLen, int offset, int len) { long[] updated = create(vectorLen + len); int idx = offset >> 6; System.arraycopy(vector, 0, updated, 0, idx); if (idx < vector.length) { int delta = offset & 63; updated[idx] |= vector[idx] & maskBelow(del...
Returns a copy of the vector, with an empty bit range inserted at the specified location. @param vector the bit vector @param vectorLen the length of the bit vector @param offset the offset within the bit vector @param len the length of the empty bit range @return an updated copy of the vector
interpose
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitVector.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitVector.java
MIT
public static long[] insert(long[] vector, int vectorLen, long val, int offset, int len) { long[] updated = interpose(vector, vectorLen, offset, len); overwrite(updated, val, offset, len); return updated; }
@param vector the bit vector @param vectorLen the length of the bit vector @param val the rowValue to be inserted @param offset the offset within the bit vector @param len the bit length of the rowValue @return an updated copy of the vector
insert
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitVector.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitVector.java
MIT
public static long[] remove(long[] vector, int vectorLen, int offset, int len) { long[] updated = create(vectorLen - len); int idx = offset >> 6; System.arraycopy(vector, 0, updated, 0, idx); if (idx < updated.length) { int delta = offset & 63; updated[idx] |= vector[idx] & maskBelow(delta...
Returns a copy of the vector, with a bit range excised from the specified location. @param vector the bit vector @param vectorLen the length of the bit vector @param offset the offset within the bit vector @param len the length of the excised bit range @return an updated copy of the vector
remove
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/BitVector.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/BitVector.java
MIT
public static long doubleToLong(double value) { long v = Double.doubleToRawLongBits(value); if (v == NEGATIVE_ZERO) { return 0; } if (value < -0.0) { v ^= Long.MAX_VALUE; } return v; }
Converts a double into a corresponding long that shares the same ordering semantics.
doubleToLong
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Encodings.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Encodings.java
MIT
public static double longToDouble(long value) { if (value < -0.0) { value ^= Long.MAX_VALUE; } return Double.longBitsToDouble(value); }
The inverse operation for {@link #doubleToLong(double)}.
longToDouble
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Encodings.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Encodings.java
MIT
public static OfInt filter(OfInt it, IntPredicate f) { return new OfInt() { private int next = 0; private boolean primed = false; private boolean done = false; private void prime() { if (!primed && !done) { while (it.hasNext()) { next = it.nextInt(); ...
@param it an iterator @param f a predicate @return an iterator which only yields values that satisfy the predicate
filter
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
private void prime() { if (!primed && !done) { while (it.hasNext()) { next = it.nextInt(); if (f.test(next)) { primed = true; return; } } done = true; } }
@param it an iterator @param f a predicate @return an iterator which only yields values that satisfy the predicate
prime
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
@Override public boolean hasNext() { prime(); return !done; }
@param it an iterator @param f a predicate @return an iterator which only yields values that satisfy the predicate
hasNext
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
@Override public int nextInt() { prime(); if (!primed) { throw new NoSuchElementException(); } primed = false; return next; }
@param it an iterator @param f a predicate @return an iterator which only yields values that satisfy the predicate
nextInt
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
public static OfInt map(OfInt it, IntUnaryOperator f) { return new OfInt() { @Override public boolean hasNext() { return it.hasNext(); } @Override public int nextInt() { return f.applyAsInt(it.nextInt()); } }; }
@param it an iterator @param f a function which transforms values @return an iterator which yields the transformed values
map
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
@Override public boolean hasNext() { return it.hasNext(); }
@param it an iterator @param f a function which transforms values @return an iterator which yields the transformed values
hasNext
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
@Override public int nextInt() { return f.applyAsInt(it.nextInt()); }
@param it an iterator @param f a function which transforms values @return an iterator which yields the transformed values
nextInt
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
public static <U> OfInt flatMap(Iterator<U> it, Function<U, OfInt> f) { return new OfInt() { OfInt curr = EMPTY; private void prime() { while (!curr.hasNext() && it.hasNext()) { curr = f.apply(it.next()); } } @Override public boolean hasNext() { pri...
@param it an iterator @param f a function which transforms values into iterators @return an iterator which yields the concatenation of the iterators
flatMap
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
private void prime() { while (!curr.hasNext() && it.hasNext()) { curr = f.apply(it.next()); } }
@param it an iterator @param f a function which transforms values into iterators @return an iterator which yields the concatenation of the iterators
prime
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
@Override public boolean hasNext() { prime(); return curr.hasNext(); }
@param it an iterator @param f a function which transforms values into iterators @return an iterator which yields the concatenation of the iterators
hasNext
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
@Override public int nextInt() { prime(); return curr.nextInt(); }
@param it an iterator @param f a function which transforms values into iterators @return an iterator which yields the concatenation of the iterators
nextInt
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
public static OfInt range(long min, long max, LongToIntFunction f) { return new OfInt() { long i = min; @Override public boolean hasNext() { return i < max; } @Override public int nextInt() { if (hasNext()) { return f.applyAsInt(i++); } else {...
@param min an inclusive start of the range @param max an exclusive end of the range @param f a function which transforms a number in the range into a value @return an iterator which yields the values returned by {@code f}
range
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
@Override public boolean hasNext() { return i < max; }
@param min an inclusive start of the range @param max an exclusive end of the range @param f a function which transforms a number in the range into a value @return an iterator which yields the values returned by {@code f}
hasNext
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
@Override public int nextInt() { if (hasNext()) { return f.applyAsInt(i++); } else { throw new NoSuchElementException(); } }
@param min an inclusive start of the range @param max an exclusive end of the range @param f a function which transforms a number in the range into a value @return an iterator which yields the values returned by {@code f}
nextInt
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
public static OfInt range(long max, LongToIntFunction f) { return range(0, max, f); }
Represents a range implicitly starting at 0. @param max an exclusive end of the range. @param f a function which transforms a number in the range into a value. @return an iterator which yields the values returned by {@code f}
range
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
public static IntStream toStream(OfInt it, long estimatedSize) { return StreamSupport.intStream(Spliterators.spliterator(it, estimatedSize, Spliterator.ORDERED), false); }
Represents a range implicitly starting at 0. @param max an exclusive end of the range. @param f a function which transforms a number in the range into a value. @return an iterator which yields the values returned by {@code f}
toStream
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/IntIterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/IntIterators.java
MIT
private void primeIterator() { while (iterators.size() > 0 && !iterators.first().hasNext()) { iterators.removeFirst(); } }
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
primeIterator
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public boolean hasNext() { primeIterator(); return iterators.size() > 0 && iterators.first().hasNext(); }
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
hasNext
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public V next() { primeIterator(); if (iterators.size() == 0) { throw new NoSuchElementException(); } return iterators.first().next(); }
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
next
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
public static <V> boolean equals(Iterator<V> a, Iterator<V> b, BiPredicate<V, V> equals) { while (a.hasNext()) { if (!b.hasNext()) { return false; } if (!equals.test(a.next(), b.next())) { return false; } } return !b.hasNext(); }
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
equals
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
public static <V> Iterator<V> from(BooleanSupplier hasNext, Supplier<V> next) { return new Iterator<V>() { @Override public boolean hasNext() { return hasNext.getAsBoolean(); } @Override public V next() { return next.get(); } }; }
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public boolean hasNext() { return hasNext.getAsBoolean(); }
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
hasNext
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public V next() { return next.get(); }
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
next
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
public static <V> Iterator<V> onExhaustion(Iterator<V> it, Runnable f) { return new Iterator<V>() { @Override public boolean hasNext() { return it.hasNext(); } @Override public V next() { V result = it.next(); if (!it.hasNext()) { f.run(); } ...
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
onExhaustion
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public boolean hasNext() { return it.hasNext(); }
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
hasNext
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public V next() { V result = it.next(); if (!it.hasNext()) { f.run(); } return result; }
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
next
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
public static <V> Iterator<V> singleton(V val) { return new Iterator<V>() { boolean consumed = false; @Override public boolean hasNext() { return !consumed; } @Override public V next() { if (!consumed) { consumed = true; return val; }...
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
singleton
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public boolean hasNext() { return !consumed; }
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
hasNext
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public V next() { if (!consumed) { consumed = true; return val; } else { throw new NoSuchElementException(); } }
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated over.
next
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
public static <V> Iterator<V> filter(Iterator<V> it, Predicate<V> f) { return new Iterator<V>() { private Object next = NONE; private boolean done = false; private void prime() { if (next == NONE && !done) { while (it.hasNext()) { next = it.next(); if (f...
@param it an iterator @param f a predicate @return an iterator which only yields values that satisfy the predicate
filter
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
private void prime() { if (next == NONE && !done) { while (it.hasNext()) { next = it.next(); if (f.test((V) next)) { return; } } done = true; } }
@param it an iterator @param f a predicate @return an iterator which only yields values that satisfy the predicate
prime
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public boolean hasNext() { prime(); return !done; }
@param it an iterator @param f a predicate @return an iterator which only yields values that satisfy the predicate
hasNext
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public V next() { prime(); if (next == NONE) { throw new NoSuchElementException(); } V val = (V) next; next = NONE; return val; }
@param it an iterator @param f a predicate @return an iterator which only yields values that satisfy the predicate
next
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
public static <U, V> Iterator<V> map(Iterator<U> it, Function<U, V> f) { return from(it::hasNext, () -> f.apply(it.next())); }
@param it an iterator @param f a function which transforms values @return an iterator which yields the transformed values
map
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
public static <U, V> Iterator<V> flatMap(Iterator<U> it, Function<U, Iterator<V>> f) { return new Iterator<V>() { Iterator<V> curr = EMPTY; private void prime() { while (!curr.hasNext() && it.hasNext()) { curr = f.apply(it.next()); } } @Override public bool...
@param it an iterator @param f a function which transforms values into iterators @return an iterator which yields the concatenation of the iterators
flatMap
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
private void prime() { while (!curr.hasNext() && it.hasNext()) { curr = f.apply(it.next()); } }
@param it an iterator @param f a function which transforms values into iterators @return an iterator which yields the concatenation of the iterators
prime
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public boolean hasNext() { prime(); return curr.hasNext(); }
@param it an iterator @param f a function which transforms values into iterators @return an iterator which yields the concatenation of the iterators
hasNext
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public V next() { prime(); return curr.next(); }
@param it an iterator @param f a function which transforms values into iterators @return an iterator which yields the concatenation of the iterators
next
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
public static <V> Iterator<V> range(long min, long max, LongFunction<V> f) { return new Iterator<V>() { long i = min; @Override public boolean hasNext() { return i < max; } @Override public V next() { if (hasNext()) { return f.apply(i++); } el...
@param min an inclusive start of the range @param max an exclusive end of the range @param f a function which transforms a number in the range into a value @return an iterator which yields the values returned by {@code f}
range
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public boolean hasNext() { return i < max; }
@param min an inclusive start of the range @param max an exclusive end of the range @param f a function which transforms a number in the range into a value @return an iterator which yields the values returned by {@code f}
hasNext
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
@Override public V next() { if (hasNext()) { return f.apply(i++); } else { throw new NoSuchElementException(); } }
@param min an inclusive start of the range @param max an exclusive end of the range @param f a function which transforms a number in the range into a value @return an iterator which yields the values returned by {@code f}
next
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT
public static <V> Iterator<V> range(long max, LongFunction<V> f) { return range(0, max, f); }
Represents a range implicitly starting at 0. @param max an exclusive end of the range. @param f a function which transforms a number in the range into a value. @return an iterator which yields the values returned by {@code f}
range
java
lacuna/bifurcan
src/io/lacuna/bifurcan/utils/Iterators.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/utils/Iterators.java
MIT