code
stringlengths
25
201k
docstring
stringlengths
19
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
51
path
stringlengths
11
314
url
stringlengths
62
377
license
stringclasses
7 values
public static <V> LinearList<V> from(Collection<V> collection) { return collection.stream().collect(Lists.linearCollector(collection.size())); }
@return a list containing the entries of {@code collection}
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearList.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearList.java
MIT
public static <V> LinearList<V> from(Iterable<V> iterable) { return from(iterable.iterator()); }
@return a list containing the elements of {@code iterable}
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearList.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearList.java
MIT
public static <V> LinearList<V> from(Iterator<V> iterator) { LinearList<V> list = new LinearList<V>(); iterator.forEachRemaining(list::addLast); return list; }
@return a list containing all remaining elements of {@code iterator}
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearList.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearList.java
MIT
public static <V> LinearList<V> from(IList<V> list) { if (list.size() > Integer.MAX_VALUE) { throw new IllegalArgumentException("LinearList cannot hold more than 1 << 30 entries"); } else if (list instanceof LinearList) { return ((LinearList<V>) list).clone(); } else { return list.stream().collect(Lists.linearCollector((int) list.size())); } }
@return a list containing the elements of {@code list}
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearList.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearList.java
MIT
public V popFirst() { V val = first(); removeFirst(); return val; }
Removes, and returns, the first element of the list. @return the first element of the list @throws IndexOutOfBoundsException if the list is empty
popFirst
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearList.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearList.java
MIT
public static <K, V> LinearMap<K, V> from(IMap<K, V> map) { if (map instanceof LinearMap) { return ((LinearMap<K, V>) map).clone(); } else { LinearMap<K, V> result = new LinearMap<K, V>((int) map.size(), map.keyHash(), map.keyEquality()); map.forEach(e -> result.put(e.key(), e.value())); return result; } }
@return a copy of {@code map}, with the same equality semantics
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearMap.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearMap.java
MIT
public static <K, V> LinearMap<K, V> from(Iterator<IEntry<K, V>> iterator) { LinearMap<K, V> m = new LinearMap<>(); iterator.forEachRemaining(e -> m.put(e.key(), e.value())); return m; }
@return a map representing all remaining entries in {@code iterator}
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearMap.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearMap.java
MIT
public static <K, V> LinearMap<K, V> from(Collection<Entry<K, V>> collection) { return collection.stream().collect(Maps.linearCollector(Entry::getKey, Entry::getValue, collection.size())); }
@return a map representing the entries in {@code collection}
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearMap.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearMap.java
MIT
public static <V> LinearSet<V> from(IList<V> list) { return from(list.toList()); }
@return a set containing the elements in {@code list}
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearSet.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearSet.java
MIT
public static <V> LinearSet<V> from(java.util.Collection<V> collection) { return collection.stream().collect(Sets.linearCollector(collection.size())); }
@return a set containing the elements in {@code collection}
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearSet.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearSet.java
MIT
public static <V> LinearSet<V> from(Iterator<V> iterator) { LinearSet<V> set = new LinearSet<V>(); iterator.forEachRemaining(set::add); return set; }
@return a set containing the remaining elements in {@code iterator}
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearSet.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearSet.java
MIT
public static <V> LinearSet<V> from(Iterable<V> iterable) { return from(iterable.iterator()); }
@return a set containing the elements in {@code iterable}
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearSet.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearSet.java
MIT
public static <V> LinearSet<V> from(ISet<V> set) { if (set instanceof LinearSet) { return ((LinearSet<V>) set).clone(); } else { LinearSet<V> result = new LinearSet<V>((int) set.size(), set.valueHash(), set.valueEquality()); set.forEach(result::add); return result; } }
@return a set containing the same elements as {@code set}, with the same equality semantics
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/LinearSet.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/LinearSet.java
MIT
public static <V, U> IList<U> lazyMap(IList<V> l, Function<V, U> f) { return Lists.from( l.size(), i -> f.apply(l.nth(i)), idx -> Iterators.map(l.iterator(idx), f) ); }
Returns a list which will lazily, and repeatedly, transform each element of the input list on lookup. @param l a list @param f a transform function for the elements of the list @param <V> the element type for the input list @param <U> the element type for the result list @return the result list
lazyMap
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> boolean equals(IList<V> a, IList<V> b) { return equals(a, b, Objects::equals); }
@return true if the two lists are equal, otherwise false
equals
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> boolean equals(IList<V> a, IList<V> b, BiPredicate<V, V> equals) { if (a == b) { return true; } else if (a.size() != b.size()) { return false; } return Iterators.equals(a.iterator(), b.iterator(), equals); }
@param equals a comparison predicate for the lists of the element @return true if the two lists are equal, otherwise false
equals
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> long hash(IList<V> l) { return hash(l, Objects::hashCode, (a, b) -> (a * 31) + b); }
@return a hash for the list, which mimics the standard Java hash calculation
hash
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> long hash(IList<V> l, ToLongFunction<V> hash, LongBinaryOperator combiner) { return l.stream().mapToLong(hash).reduce(combiner).orElse(0); }
@param hash a function which provides a hash for each element @param combiner a function which combines the accumulated hash and element hash @return a hash for the list
hash
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> String toString(IList<V> l) { return toString(l, Objects::toString); }
@return a string representation of the list, using toString() to represent each element
toString
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> String toString(IList<V> l, Function<V, String> printer) { StringBuilder sb = new StringBuilder("["); Iterator<V> it = l.iterator(); while (it.hasNext()) { sb.append(printer.apply(it.next())); if (it.hasNext()) { sb.append(", "); } } sb.append("]"); return sb.toString(); }
@param printer a function which returns a string representation of an element @return a string representation fo the list
toString
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> java.util.List<V> toList(IList<V> list) { return new JavaList(list); }
@return a shim around the input list, presenting it as a standard Java List object
toList
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> IList<V> slice(IList<V> list, long start, long end) { IList<V> result; if (end <= start) { result = List.EMPTY; } else if (start < 0 || end > list.size()) { throw new IndexOutOfBoundsException("[" + start + "," + end + ") isn't a subset of [0,"+ list.size() + ")"); } else if (end - start == list.size()) { result = list; } else { result = Lists.from(end - start, i -> list.nth(i + start)); } return list.isLinear() ? result.linear() : result; }
@param start the inclusive start index of the slice @param end the exclusive end index of the slice @return a subset view of the list, which holds onto a reference to the original
slice
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> IList<V> from(V[] array) { return Lists.from(array.length, idx -> array[(int) idx]); }
@return a view of the array as an IList
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> IList<V> from(java.util.List<V> list) { LongFunction<V> nth = idx -> list.get((int) idx); return Lists.from( list.size(), nth, idx -> idx == 0 ? list.iterator() : Iterators.range(idx, list.size(), nth) ); }
@return a view of the Java list as an IList
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> IList<V> from(long size, LongFunction<V> elementFn) { return from(size, elementFn, idx -> Iterators.range(idx, size, elementFn)); }
Creates a list which repeatedly uses the element function for each lookup. @param size the size of the list @param elementFn a function which returns the list for the given element @return a list
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> Collector<V, LinearList<V>, LinearList<V>> linearCollector() { return linearCollector(8); }
@return a Java stream collector which can be used to construct a LinearList
linearCollector
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> Iterator<V> iterator(IList<V> list, long startIndex) { return Iterators.range(startIndex, list.size(), list::nth); }
@return an iterator over the list which repeatedly calls nth()
iterator
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <V> IList<V> concat(IList<V>... lists) { return Arrays.stream(lists).reduce(Lists::concat).orElseGet(List::new); }
@return a concatenation of all the lists
concat
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Lists.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Lists.java
MIT
public static <K, V> Map<K, V> from(IMap<K, V> map) { if (map instanceof Map) { return (Map<K, V>) map.forked(); } else { Map<K, V> result = new Map<K, V>(map.keyHash(), map.keyEquality()).linear(); map.forEach(e -> result.put(e.key(), e.value())); return result.forked(); } }
@param map another map @return an equivalent forked map, with the same equality semantics
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Map.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Map.java
MIT
public static <K, V> Map<K, V> from(java.util.Map<K, V> map) { return map.entrySet().stream().collect(Maps.collector(java.util.Map.Entry::getKey, java.util.Map.Entry::getValue)); }
@return a forked map with the same contents as {@code map}
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Map.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Map.java
MIT
public static <K, V> Map<K, V> from(Iterator<IEntry<K, V>> entries) { Map<K, V> m = new Map<K, V>().linear(); entries.forEachRemaining(e -> m.put(e.key(), e.value())); return m.forked(); }
@param entries an iterator of {@code IEntry} objects @return a forked map containing the remaining entries
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Map.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Map.java
MIT
public static <K, V> Map<K, V> from(IList<IEntry<K, V>> entries) { return entries.stream().collect(Maps.collector(IEntry::key, IEntry::value)); }
@param entries a list of {@code IEntry} objects @return a forked map containing these entries
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Map.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Map.java
MIT
public static Rope from(CharSequence cs) { Object editor = new Object(); Node root = new Node(editor, RopeNodes.SHIFT_INCREMENT); if (cs.length() > 0) { Iterator<byte[]> it = chunks(cs); while (it.hasNext()) { root = root.pushLast(it.next(), editor); } } return new Rope(root, false); }
@return a rope corresponding to {@code cs}
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Rope.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Rope.java
MIT
public Rope concat(Rope rope) { return new Rope(root.concat(rope.root, new Object()), isLinear()); }
@return a new Rope with {@code rope} concatenated to the end
concat
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Rope.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Rope.java
MIT
public int nth(int idx) { if (idx < 0 || idx >= size()) { throw new IndexOutOfBoundsException(); } return root.nthPoint(idx); }
@return the nth code point within the rope @throws IndexOutOfBoundsException if {@code idx} is not within {@code [0, size)}
nth
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Rope.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Rope.java
MIT
public int size() { return root.numCodePoints(); }
@return the number of code points in the rope
size
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Rope.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Rope.java
MIT
public Rope insert(int idx, Rope rope) { if (rope.size() == 0) { return this; } return insert(idx, rope.chunks(), rope.root.numCodeUnits()); }
@return a new rope with {@code rope} inserted after the first {@code idx} code points
insert
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Rope.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Rope.java
MIT
public Rope insert(int index, CharSequence cs) { if (cs.length() == 0) { return this; } return insert(index, chunks(cs), cs.length()); }
@return a new rope with {@code cs} inserted after the first {@code index} code points
insert
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Rope.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Rope.java
MIT
public Iterator<ByteBuffer> bytes() { return Iterators.map(chunks(), ary -> ByteBuffer.wrap(ary, 2, ary.length - 2).slice()); }
@return a sequence of bytes representing the UTF-8 encoding of the rope
bytes
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Rope.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Rope.java
MIT
public PrimitiveIterator.OfInt reverseChars() { return IntIterators.flatMap(reverseChunks(), UnicodeChunk::reverseCodeUnitIterator); }
@return a sequence of integers representing the UTF-16 code units from back to front
reverseChars
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Rope.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Rope.java
MIT
public PrimitiveIterator.OfInt chars() { return IntIterators.flatMap(chunks(), UnicodeChunk::codeUnitIterator); }
@return a sequence of integers representing the UTF-16 code units from front to back
chars
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Rope.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Rope.java
MIT
public PrimitiveIterator.OfInt reverseCodePoints() { return IntIterators.flatMap(reverseChunks(), UnicodeChunk::reverseCodePointIterator); }
@return a sequence of integers representing the code points from back to front
reverseCodePoints
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Rope.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Rope.java
MIT
public PrimitiveIterator.OfInt codePoints() { return IntIterators.flatMap(chunks(), UnicodeChunk::codePointIterator); }
@return a sequence of integers representing the code points from front to back
codePoints
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Rope.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Rope.java
MIT
@Override public String toString() { char[] cs = new char[root.numCodeUnits()]; Iterator<byte[]> it = chunks(); int offset = 0; while (it.hasNext()) { offset += UnicodeChunk.writeCodeUnits(cs, offset, it.next()); } return new String(cs); }
@return a corresponding Java-style {@code String} in {@code O(N)} time
toString
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Rope.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Rope.java
MIT
public static <V> Set<V> from(ISet<V> s) { if (s instanceof Set) { return ((Set<V>) s).forked(); } else { Set<V> result = new Set<V>(s.valueHash(), s.valueEquality()).linear(); s.forEach(result::add); return result.forked(); } }
@param s a set @return an equivalent set, with the same equality semantics
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Set.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Set.java
MIT
public static <V> Set<V> from(Iterator<V> iterator) { Set<V> set = new Set<V>().linear(); iterator.forEachRemaining(set::add); return set.forked(); }
@param iterator an iterator @return a set containing the remaining values in the iterator
from
java
lacuna/bifurcan
src/io/lacuna/bifurcan/Set.java
https://github.com/lacuna/bifurcan/blob/master/src/io/lacuna/bifurcan/Set.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 > val) { high = mid - 1; } else { return mid; } } return -(low + 1); }
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 rowValue represents the table where the rowValue would be inserted, where -1 represents the 0th element, -2 represents the 1st element, and so on.
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 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 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 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 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 - truncatedLen)) << truncatedLen; } return val; }
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 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 chunkLen = Math.min(srcRemainder, dstRemainder); long mask = maskBelow(chunkLen) << srcIdx; dst[dstOffset >> 6] |= ((src[srcOffset >> 6] & mask) >>> srcIdx) << dstOffset; srcOffset += chunkLen; dstOffset += chunkLen; } }
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(delta); } copy(vector, offset, updated, offset + len, vectorLen - offset); return updated; }
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); } copy(vector, offset + len, updated, offset, vectorLen - (offset + len)); return updated; }
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 <V> Iterator<V> concat(Iterator<V>... iterators) { if (iterators.length == 1) { return iterators[0]; } else { IteratorStack<V> stack = new IteratorStack<V>(); for (Iterator<V> it : iterators) { stack.addLast(it); } return stack; } }
@param iterators a list of iterators @return a concatenation of all iterators, in the order provided
concat
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 void afterPropertiesSet() { logger.debug( "Not found configuration for registering mapper bean using @MapperScan, MapperFactoryBean and MapperScannerConfigurer."); }
If mapper registering configuration or mapper scanning configuration not present, this configuration allow to scan mappers based on the same component-scanning path as Spring Boot itself.
afterPropertiesSet
java
mybatis/spring-boot-starter
mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.java
https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.java
Apache-2.0
@Bean @ConditionalOnMissingBean FreeMarkerLanguageDriver freeMarkerLanguageDriver() { return new FreeMarkerLanguageDriver(); }
Configuration class for mybatis-freemarker 1.1.x or under.
freeMarkerLanguageDriver
java
mybatis/spring-boot-starter
mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfiguration.java
https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfiguration.java
Apache-2.0
@Bean @ConditionalOnMissingBean org.mybatis.scripting.velocity.Driver velocityLanguageDriver() { return new org.mybatis.scripting.velocity.Driver(); }
Configuration class for mybatis-velocity 2.0 or under.
velocityLanguageDriver
java
mybatis/spring-boot-starter
mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfiguration.java
https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfiguration.java
Apache-2.0
public static void setUrlDecodingCharset(Charset charset) { urlDecodingCharset = charset; }
Set the charset for decoding an encoded URL string. <p> Default is system default charset. </p> @param charset the charset for decoding an encoded URL string @since 2.3.0
setUrlDecodingCharset
java
mybatis/spring-boot-starter
mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/SpringBootVFS.java
https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/SpringBootVFS.java
Apache-2.0
@Test void testProperties() throws IOException { DocumentContext documentContext = JsonPath .parse(new FileSystemResource("src/main/resources/META-INF/additional-spring-configuration-metadata.json") .getInputStream()); List<Map<String, Object>> properties = documentContext.read("$.properties"); assertAll(() -> assertThat(properties.size()).isEqualTo(4), () -> { // assert for mybatis.lazy-initialization Map<String, Object> element = properties.get(0); assertThat(element.get("defaultValue")).isEqualTo(false); assertThat(element.get("name")).isEqualTo("mybatis.lazy-initialization"); assertThat(element.get("type")).isEqualTo("java.lang.Boolean"); }, () -> { // assert for mybatis.mapper-default-scope Map<String, Object> element = properties.get(1); assertThat(element.get("defaultValue")).isEqualTo(""); assertThat(element.get("name")).isEqualTo("mybatis.mapper-default-scope"); assertThat(element.get("type")).isEqualTo("java.lang.String"); }, () -> { // assert for mybatis.inject-sql-session-on-mapper-scan Map<String, Object> element = properties.get(2); assertThat(element.get("defaultValue")).isEqualTo(true); assertThat(element.get("name")).isEqualTo("mybatis.inject-sql-session-on-mapper-scan"); assertThat(element.get("type")).isEqualTo("java.lang.Boolean"); }, () -> { // assert for mybatis.scripting-language-driver.velocity.userdirective Map<String, Object> element = properties.get(3); assertThat(element.get("name")).isEqualTo("mybatis.scripting-language-driver.velocity.userdirective"); @SuppressWarnings("unchecked") Map<String, Object> deprecation = (Map<String, Object>) element.get("deprecation"); assertThat(deprecation.get("level")).isEqualTo("error"); assertThat(deprecation.get("reason")).isEqualTo( "The 'userdirective' is deprecated since Velocity 2.x. This property defined for keeping backward compatibility with older velocity version."); assertThat(deprecation.get("replacement")) .isEqualTo("mybatis.scripting-language-driver.velocity.velocity-settings.runtime.custom_directives"); }); }
Tests for definition of additional-spring-configuration-metadata.json. @author Kazuki Shimizu @since 1.3.1
testProperties
java
mybatis/spring-boot-starter
mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/AdditionalConfigurationMetadataTest.java
https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/AdditionalConfigurationMetadataTest.java
Apache-2.0
@Test void selectCityByIdTest() { City city = cityDao.selectCityById(1); assertThat(city.getId()).isEqualTo(1); assertThat(city.getName()).isEqualTo("San Francisco"); assertThat(city.getState()).isEqualTo("CA"); assertThat(city.getCountry()).isEqualTo("US"); }
Tests for {@link CityDao}. @author wonwoo @since 1.2.1
selectCityByIdTest
java
mybatis/spring-boot-starter
mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/test/java/sample/mybatis/xml/dao/CityDaoTest.java
https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/test/java/sample/mybatis/xml/dao/CityDaoTest.java
Apache-2.0
@Test void selectByCityIdTest() { Hotel hotel = hotelMapper.selectByCityId(1); assertThat(hotel.getCity()).isEqualTo(1); assertThat(hotel.getName()).isEqualTo("Conrad Treasury Place"); assertThat(hotel.getAddress()).isEqualTo("William & George Streets"); assertThat(hotel.getZip()).isEqualTo("4001"); }
Tests for {@link HotelMapper}. @author wonwoo @since 1.2.1
selectByCityIdTest
java
mybatis/spring-boot-starter
mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/test/java/sample/mybatis/xml/mapper/HotelMapperTest.java
https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/test/java/sample/mybatis/xml/mapper/HotelMapperTest.java
Apache-2.0
@Override protected String[] getProperties(Class<?> testClass) { MybatisTest annotation = AnnotatedElementUtils.getMergedAnnotation(testClass, MybatisTest.class); return (annotation != null) ? annotation.properties() : null; }
{@link TestContextBootstrapper} for {@link MybatisTest @MybatisTest} support. @author Kazuki Shimizu @since 2.1.0
getProperties
java
mybatis/spring-boot-starter
mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestContextBootstrapper.java
https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestContextBootstrapper.java
Apache-2.0
public String getMessage() { return "Hello!"; }
Example component that annotated {@link Component @Component} used with {@link MybatisTest} tests. @author wonwoo @since 1.2.1
getMessage
java
mybatis/spring-boot-starter
mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleComponent.java
https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleComponent.java
Apache-2.0
public String getMessage() { return "Goodbye!"; }
Example component that annotated {@link Service @Service} used with {@link MybatisTest} tests. @author Kazuki Shimizu @since 1.2.1
getMessage
java
mybatis/spring-boot-starter
mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleService.java
https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleService.java
Apache-2.0
void add(T value) { final int c = capacity; int o = offset; if (o == c) { Object[] next = new Object[c + 1]; tail[c] = next; tail = next; o = 0; } tail[o] = value; offset = o + 1; }
Append a non-null value to the list. <p>Don't add null to the list! @param value the value to append
add
java
JakeWharton/RxRelay
src/main/java/com/jakewharton/rxrelay3/AppendOnlyLinkedArrayList.java
https://github.com/JakeWharton/RxRelay/blob/master/src/main/java/com/jakewharton/rxrelay3/AppendOnlyLinkedArrayList.java
Apache-2.0
@CheckReturnValue @NonNull public static <T> BehaviorRelay<T> create() { return new BehaviorRelay<T>(); }
Creates a {@link BehaviorRelay} without a default item.
create
java
JakeWharton/RxRelay
src/main/java/com/jakewharton/rxrelay3/BehaviorRelay.java
https://github.com/JakeWharton/RxRelay/blob/master/src/main/java/com/jakewharton/rxrelay3/BehaviorRelay.java
Apache-2.0
void add(PublishDisposable<T> ps) { for (;;) { PublishDisposable<T>[] a = subscribers.get(); int n = a.length; @SuppressWarnings("unchecked") PublishDisposable<T>[] b = new PublishDisposable[n + 1]; System.arraycopy(a, 0, b, 0, n); b[n] = ps; if (subscribers.compareAndSet(a, b)) { return; } } }
Adds the given subscriber to the subscribers array atomically. @param ps the subscriber to add
add
java
JakeWharton/RxRelay
src/main/java/com/jakewharton/rxrelay3/PublishRelay.java
https://github.com/JakeWharton/RxRelay/blob/master/src/main/java/com/jakewharton/rxrelay3/PublishRelay.java
Apache-2.0
@NonNull @CheckReturnValue public final Relay<T> toSerialized() { if (this instanceof SerializedRelay) { return this; } return new SerializedRelay<T>(this); }
Wraps this Relay and serializes the calls to {@link #accept}, making it thread-safe. <p>The method is thread-safe.
toSerialized
java
JakeWharton/RxRelay
src/main/java/com/jakewharton/rxrelay3/Relay.java
https://github.com/JakeWharton/RxRelay/blob/master/src/main/java/com/jakewharton/rxrelay3/Relay.java
Apache-2.0
@CheckReturnValue @NonNull public static <T> ReplayRelay<T> create() { return new ReplayRelay<T>(new UnboundedReplayBuffer<T>(16)); }
Creates an unbounded replay relay. <p> The internal buffer is backed by an {@link ArrayList} and starts with an initial capacity of 16. Once the number of items reaches this capacity, it will grow as necessary (usually by 50%). However, as the number of items grows, this causes frequent array reallocation and copying, and may hurt performance and latency. This can be avoided with the {@link #create(int)} overload which takes an initial capacity parameter and can be tuned to reduce the array reallocation frequency as needed.
create
java
JakeWharton/RxRelay
src/main/java/com/jakewharton/rxrelay3/ReplayRelay.java
https://github.com/JakeWharton/RxRelay/blob/master/src/main/java/com/jakewharton/rxrelay3/ReplayRelay.java
Apache-2.0
@CheckReturnValue @NonNull public static <T> ReplayRelay<T> create(int capacityHint) { return new ReplayRelay<T>(new UnboundedReplayBuffer<T>(capacityHint)); }
Creates an unbounded replay relay with the specified initial buffer capacity. <p> Use this method to avoid excessive array reallocation while the internal buffer grows to accommodate new items. For example, if you know that the buffer will hold 32k items, you can ask the {@code ReplayRelay} to preallocate its internal array with a capacity to hold that many items. Once the items start to arrive, the internal array won't need to grow, creating less garbage and no overhead due to frequent array-copying. @param capacityHint the initial buffer capacity
create
java
JakeWharton/RxRelay
src/main/java/com/jakewharton/rxrelay3/ReplayRelay.java
https://github.com/JakeWharton/RxRelay/blob/master/src/main/java/com/jakewharton/rxrelay3/ReplayRelay.java
Apache-2.0
@CheckReturnValue @NonNull public static <T> ReplayRelay<T> createWithSize(int maxSize) { return new ReplayRelay<T>(new SizeBoundReplayBuffer<T>(maxSize)); }
Creates a size-bounded replay relay. <p> In this setting, the {@code ReplayRelay} holds at most {@code size} items in its internal buffer and discards the oldest item. <p> When observers subscribe to a terminated {@code ReplayRelay}, they are guaranteed to see at most {@code size} {@code onNext} events followed by a termination event. <p> If an observer subscribes while the {@code ReplayRelay} is active, it will observe all items in the buffer at that point in time and each item observed afterwards, even if the buffer evicts items due to the size constraint in the mean time. In other words, once an Observer subscribes, it will receive items without gaps in the sequence. @param maxSize the maximum number of buffered items
createWithSize
java
JakeWharton/RxRelay
src/main/java/com/jakewharton/rxrelay3/ReplayRelay.java
https://github.com/JakeWharton/RxRelay/blob/master/src/main/java/com/jakewharton/rxrelay3/ReplayRelay.java
Apache-2.0
static <T> ReplayRelay<T> createUnbounded() { return new ReplayRelay<T>(new SizeBoundReplayBuffer<T>(Integer.MAX_VALUE)); }
Creates an unbounded replay replay with the bounded-implementation for testing purposes. <p> This variant behaves like the regular unbounded {@code ReplayRelay} created via {@link #create()} but uses the structures of the bounded-implementation. This is by no means intended for the replacement of the original, array-backed and unbounded {@code ReplayRelay} due to the additional overhead of the linked-list based internal buffer. The sole purpose is to allow testing and reasoning about the behavior of the bounded implementations without the interference of the eviction policies.
createUnbounded
java
JakeWharton/RxRelay
src/main/java/com/jakewharton/rxrelay3/ReplayRelay.java
https://github.com/JakeWharton/RxRelay/blob/master/src/main/java/com/jakewharton/rxrelay3/ReplayRelay.java
Apache-2.0
@CheckReturnValue @NonNull public static <T> ReplayRelay<T> createWithTime(long maxAge, TimeUnit unit, Scheduler scheduler) { return new ReplayRelay<T>(new SizeAndTimeBoundReplayBuffer<T>(Integer.MAX_VALUE, maxAge, unit, scheduler)); }
Creates a time-bounded replay relay. <p> In this setting, the {@code ReplayRelay} internally tags each observed item with a timestamp value supplied by the {@link Scheduler} and keeps only those whose age is less than the supplied time value converted to milliseconds. For example, an item arrives at T=0 and the max age is set to 5; at T&gt;=5 this first item is then evicted by any subsequent item or termination event, leaving the buffer empty. <p> Once the subject is terminated, observers subscribing to it will receive items that remained in the buffer after the terminal event, regardless of their age. <p> If an observer subscribes while the {@code ReplayRelay} is active, it will observe only those items from within the buffer that have an age less than the specified time, and each item observed thereafter, even if the buffer evicts items due to the time constraint in the mean time. In other words, once an observer subscribes, it observes items without gaps in the sequence except for any outdated items at the beginning of the sequence. <p> Note that terminal notifications ({@code onError} and {@code onComplete}) trigger eviction as well. For example, with a max age of 5, the first item is observed at T=0, then an {@code onComplete} notification arrives at T=10. If an observer subscribes at T=11, it will find an empty {@code ReplayRelay} with just an {@code onComplete} notification. @param maxAge the maximum age of the contained items @param unit the time unit of {@code time} @param scheduler the {@link Scheduler} that provides the current time
createWithTime
java
JakeWharton/RxRelay
src/main/java/com/jakewharton/rxrelay3/ReplayRelay.java
https://github.com/JakeWharton/RxRelay/blob/master/src/main/java/com/jakewharton/rxrelay3/ReplayRelay.java
Apache-2.0
public Object[] getValues() { @SuppressWarnings("unchecked") T[] a = (T[])EMPTY_ARRAY; T[] b = getValues(a); if (b == EMPTY_ARRAY) { return new Object[0]; } return b; }
Returns an Object array containing snapshot all values of the Relay. <p>The method is thread-safe.
getValues
java
JakeWharton/RxRelay
src/main/java/com/jakewharton/rxrelay3/ReplayRelay.java
https://github.com/JakeWharton/RxRelay/blob/master/src/main/java/com/jakewharton/rxrelay3/ReplayRelay.java
Apache-2.0
@SuppressWarnings("unchecked") public static <T> io.reactivex.rxjava3.core.Observer<T> mockObserver() { return mock(io.reactivex.rxjava3.core.Observer.class); }
Mocks an Observer with the proper receiver type. @param <T> the value type @return the mocked observer
mockObserver
java
JakeWharton/RxRelay
src/test/java/com/jakewharton/rxrelay3/TestHelper.java
https://github.com/JakeWharton/RxRelay/blob/master/src/test/java/com/jakewharton/rxrelay3/TestHelper.java
Apache-2.0
public static void render() { // If Anvil.render() is called on a non-UI thread, use UI Handler if (Looper.myLooper() != Looper.getMainLooper()) { synchronized (Anvil.class) { if (anvilUIHandler == null) { anvilUIHandler = new Handler(Looper.getMainLooper()); } } anvilUIHandler.removeCallbacksAndMessages(null); anvilUIHandler.post(anvilRenderRunnable); return; } Set<Mount> set = new HashSet<>(); set.addAll(mounts.values()); for (Mount m : set) { render(m); } }
Starts the new rendering cycle updating all mounted renderables. Update happens in a lazy manner, only the values that has been changed since last rendering cycle will be actually updated in the views. This method can be called from any thread, so it's safe to use {@code Anvil.render()} in background services.
render
java
anvil-ui/anvil
anvil/src/main/java/trikita/anvil/Anvil.java
https://github.com/anvil-ui/anvil/blob/master/anvil/src/main/java/trikita/anvil/Anvil.java
MIT
public static <T extends View> T mount(T v, Renderable r) { Mount m = new Mount(v, r); mounts.put(v, m); render(v); return v; }
Mounts a renderable function defining the layout into a View. If host is a viewgroup it is assumed to be empty, so the Renderable would define what its child views would be. @param v a View into which the renderable r will be mounted @param r a Renderable to mount into a View
mount
java
anvil-ui/anvil
anvil/src/main/java/trikita/anvil/Anvil.java
https://github.com/anvil-ui/anvil/blob/master/anvil/src/main/java/trikita/anvil/Anvil.java
MIT
static Mount currentMount() { return currentMount; }
Returns currently rendered Mount point. Must be called from the Renderable's view() method, otherwise it returns null @return current mount point
currentMount
java
anvil-ui/anvil
anvil/src/main/java/trikita/anvil/Anvil.java
https://github.com/anvil-ui/anvil/blob/master/anvil/src/main/java/trikita/anvil/Anvil.java
MIT
public void showFor(long millis) { mView.postDelayed(mTimeoutRunnable, millis); show(); }
Displays the prompt for a maximum amount of time. @param millis The number of milliseconds to show the prompt for.
showFor
java
sjwall/MaterialTapTargetPrompt
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
Apache-2.0
public void cancelShowForTimer() { mView.removeCallbacks(mTimeoutRunnable); }
Cancel the show for timer if it has been created.
cancelShowForTimer
java
sjwall/MaterialTapTargetPrompt
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
Apache-2.0
public int getState() { return mState; }
Get the current state of the prompt. @see #STATE_NOT_SHOWN @see #STATE_REVEALING @see #STATE_REVEALED @see #STATE_FOCAL_PRESSED @see #STATE_NON_FOCAL_PRESSED @see #STATE_BACK_BUTTON_PRESSED @see #STATE_FINISHING @see #STATE_FINISHED @see #STATE_DISMISSING @see #STATE_DISMISSED
getState
java
sjwall/MaterialTapTargetPrompt
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
Apache-2.0
boolean isStarting() { return mState == STATE_REVEALING || mState == STATE_REVEALED; }
Is the current state {@link #STATE_REVEALING} or {@link #STATE_REVEALED}. @return True if revealing or revealed.
isStarting
java
sjwall/MaterialTapTargetPrompt
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
Apache-2.0
boolean isDismissing() { return mState == STATE_DISMISSING || mState == STATE_FINISHING; }
Is the current state {@link #STATE_DISMISSING} or {@link #STATE_FINISHING}. @return True if dismissing or finishing.
isDismissing
java
sjwall/MaterialTapTargetPrompt
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
Apache-2.0
boolean isDismissed() { return mState == STATE_DISMISSED || mState == STATE_FINISHED; }
Is the current state {@link #STATE_DISMISSED} or {@link #STATE_FINISHED}. @return True if dismissed or finished.
isDismissed
java
sjwall/MaterialTapTargetPrompt
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
Apache-2.0
boolean isComplete() { return mState == STATE_NOT_SHOWN || isDismissing() || isDismissed(); }
Is the current state neither {@link #STATE_REVEALED} or {@link #STATE_REVEALING}. @return True if not revealed or revealing.
isComplete
java
sjwall/MaterialTapTargetPrompt
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
Apache-2.0
void addGlobalLayoutListener() { final ViewTreeObserver viewTreeObserver = ((ViewGroup) mView.getParent()).getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener(mGlobalLayoutListener); } }
Adds layout listener to view parent to capture layout changes.
addGlobalLayoutListener
java
sjwall/MaterialTapTargetPrompt
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
Apache-2.0
void removeGlobalLayoutListener() { final ViewGroup parent = (ViewGroup) mView.getParent(); if (parent == null) { return; } final ViewTreeObserver viewTreeObserver = ((ViewGroup) mView.getParent()).getViewTreeObserver(); if (viewTreeObserver.isAlive()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { viewTreeObserver.removeOnGlobalLayoutListener(mGlobalLayoutListener); } else { viewTreeObserver.removeGlobalOnLayoutListener(mGlobalLayoutListener); } } }
Removes global layout listener added in {@link #addGlobalLayoutListener()}.
removeGlobalLayoutListener
java
sjwall/MaterialTapTargetPrompt
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
Apache-2.0
void cleanUpPrompt(final int state) { cleanUpAnimation(); removeGlobalLayoutListener(); final ViewGroup parent = (ViewGroup) mView.getParent(); if (parent != null) { parent.removeView(mView); } if (isDismissing()) { onPromptStateChanged(state); } }
Removes the prompt from view and triggers the {@link #onPromptStateChanged(int)} event.
cleanUpPrompt
java
sjwall/MaterialTapTargetPrompt
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/MaterialTapTargetPrompt.java
Apache-2.0