Package edu.berkeley.nlp.lm.array
Class CustomWidthArray
- java.lang.Object
-
- edu.berkeley.nlp.lm.array.CustomWidthArray
-
- All Implemented Interfaces:
java.io.Serializable
public final class CustomWidthArray extends java.lang.Object implements java.io.SerializableAn array with a custom word "width" in bits. Borrows heavily from Sux4J (http://sux.dsi.unimi.it/)- Author:
- adampauls
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CustomWidthArray(long numWords, int keyWidth)CustomWidthArray(long numWords, int keyWidth, int fullWidth)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(long value)booleanaddWithFixedCapacity(long value)voidclear(long index)voidensureCapacity(long numWords)voidfill(long l, long n)longget(long index)longget(long index, int offset, int width)booleangetBit(long index)intgetFullWidth()intgetKeyWidth()voidincrementCount(long index, long count)longlinearSearch(long key, long rangeStart, long rangeEnd, long startIndex, long emptyKey, boolean returnFirstEmptyIndex)static intnumBitsNeeded(long n)voidset(long index, long value)voidset(long index, long value, int offset, int width)voidsetAndGrowIfNeeded(long pos, long value)voidsetAndGrowIfNeeded(long pos, long value, int offset, int width)longsize()voidtrim()voidtrimToSize(long sizeHere)
-
-
-
Method Detail
-
getKeyWidth
public int getKeyWidth()
-
ensureCapacity
public void ensureCapacity(long numWords)
-
trim
public void trim()
-
trimToSize
public void trimToSize(long sizeHere)
- Parameters:
sizeHere-
-
getBit
public boolean getBit(long index)
-
clear
public void clear(long index)
-
add
public boolean add(long value)
-
addWithFixedCapacity
public boolean addWithFixedCapacity(long value)
-
get
public long get(long index)
-
get
public long get(long index, int offset, int width)
-
numBitsNeeded
public static int numBitsNeeded(long n)
-
set
public void set(long index, long value)
-
set
public void set(long index, long value, int offset, int width)
-
setAndGrowIfNeeded
public void setAndGrowIfNeeded(long pos, long value)
-
setAndGrowIfNeeded
public void setAndGrowIfNeeded(long pos, long value, int offset, int width)
-
size
public long size()
-
fill
public void fill(long l, long n)
-
linearSearch
public long linearSearch(long key, long rangeStart, long rangeEnd, long startIndex, long emptyKey, boolean returnFirstEmptyIndex)
-
incrementCount
public void incrementCount(long index, long count)
-
getFullWidth
public int getFullWidth()
-
-