本文整理匯總了Java中cern.colt.bitvector.QuickBitVector類的典型用法代碼示例。如果您正苦於以下問題:Java QuickBitVector類的具體用法?Java QuickBitVector怎麽用?Java QuickBitVector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
QuickBitVector類屬於cern.colt.bitvector包,在下文中一共展示了QuickBitVector類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addAllOfFromTo
import cern.colt.bitvector.QuickBitVector; //導入依賴的package包/類
/**
* Appends the elements <tt>elements[from]</tt> (inclusive), ..., <tt>elements[to]</tt> (inclusive) to the receiver.
* @param elements the elements to be appended to the receiver.
* @param from the index of the first element to be appended (inclusive)
* @param to the index of the last element to be appended (inclusive)
*/
public void addAllOfFromTo(long[] elements, int from, int to) {
// cache some vars for speed.
int bitsPerElem = this.bitsPerElement;
int bitsPerElemMinusOne = bitsPerElem-1;
long min = this.minValue;
long[] theBits = this.bits;
// now let's go.
ensureCapacity(this.size+to-from+1);
int firstBit = this.size*bitsPerElem;
int i=from;
for (int times=to-from+1; --times >=0; ) {
QuickBitVector.putLongFromTo(theBits, elements[i++]-min, firstBit, firstBit+bitsPerElemMinusOne);
firstBit += bitsPerElem;
}
this.size += (to-from+1); //*bitsPerElem;
}
示例2: partFromTo
import cern.colt.bitvector.QuickBitVector; //導入依賴的package包/類
/**
* Copies all elements between index <tt>from</tt> (inclusive) and <tt>to</tt> (inclusive) into <tt>part</tt>, starting at index <tt>partFrom</tt> within <tt>part</tt>.
* Elements are only copied if a corresponding flag within <tt>qualificants</tt> is set.
* More precisely:<pre>
* for (; from<=to; from++, partFrom++, qualificantsFrom++) {
* if (qualificants==null || qualificants.get(qualificantsFrom)) {
* part[partFrom] = this.get(from);
* }
* }
* </pre>
*/
public void partFromTo(final int from, final int to, final BitVector qualificants, final int qualificantsFrom, long[] part, final int partFrom) {
int width = to-from+1;
if (from<0 || from>to || to>=size || qualificantsFrom<0 || (qualificants!=null && qualificantsFrom+width>qualificants.size())) {
throw new IndexOutOfBoundsException();
}
if (partFrom<0 || partFrom+width>part.length) {
throw new IndexOutOfBoundsException();
}
long minVal = this.minValue;
int bitsPerElem = this.bitsPerElement;
long[] theBits = this.bits;
int q = qualificantsFrom;
int p = partFrom;
int j=from*bitsPerElem;
//BitVector tmpBitVector = new BitVector(this.bits, this.size*bitsPerElem);
for (int i=from; i<=to; i++, q++, p++, j += bitsPerElem) {
if (qualificants==null || qualificants.get(q)) {
//part[p] = minVal + tmpBitVector.getLongFromTo(j, j+bitsPerElem-1);
part[p] = minVal + QuickBitVector.getLongFromTo(theBits, j, j+bitsPerElem-1);
}
}
}
示例3: add
import cern.colt.bitvector.QuickBitVector; //導入依賴的package包/類
/**
* Appends the specified element to the end of this list.
*
* @param element element to be appended to this list.
*/
public void add(long element) {
// overridden for performance only.
if (size == capacity) {
ensureCapacity(size + 1);
}
int i=size*this.bitsPerElement;
QuickBitVector.putLongFromTo(this.bits, element-this.minValue,i,i+this.bitsPerElement-1);
size++;
}
示例4: setUp
import cern.colt.bitvector.QuickBitVector; //導入依賴的package包/類
/**
* Sets the receiver to an empty list with the specified initial capacity and the specified range of values allowed to be hold in this list.
* Legal values are in the range [minimum,maximum], all inclusive.
* @param minimum the minimum of values allowed to be hold in this list.
* @param maximum the maximum of values allowed to be hold in this list.
* @param initialCapacity the number of elements the receiver can hold without auto-expanding itself by allocating new internal memory.
*/
protected void setUp(long minimum, long maximum, int initialCapacity) {
setUpBitsPerEntry(minimum, maximum);
//this.capacity=initialCapacity;
this.bits = QuickBitVector.makeBitVector(initialCapacity,this.bitsPerElement);
this.capacity = initialCapacity;
this.size=0;
}
示例5: getQuick
import cern.colt.bitvector.QuickBitVector; //導入依賴的package包/類
/**
* Returns the element at the specified position in the receiver; <b>WARNING:</b> Does not check preconditions.
* Provided with invalid parameters this method may return invalid elements without throwing any exception!
* <b>You should only use this method when you are absolutely sure that the index is within bounds.</b>
* Precondition (unchecked): <tt>index >= 0 && index < size()</tt>.
*
* @param index index of element to return.
*/
public long getQuick(int index) {
int i=index*this.bitsPerElement;
return this.minValue + QuickBitVector.getLongFromTo(this.bits, i,i+this.bitsPerElement-1);
}
示例6: setQuick
import cern.colt.bitvector.QuickBitVector; //導入依賴的package包/類
/**
* Replaces the element at the specified position in the receiver with the specified element; <b>WARNING:</b> Does not check preconditions.
* Provided with invalid parameters this method may access invalid indexes without throwing any exception!
* <b>You should only use this method when you are absolutely sure that the index is within bounds.</b>
* Precondition (unchecked): <tt>index >= 0 && index < size()</tt>.
*
* @param index index of element to replace.
* @param element element to be stored at the specified position.
*/
public void setQuick(int index, long element) {
int i=index*this.bitsPerElement;
QuickBitVector.putLongFromTo(this.bits, element-this.minValue,i,i+this.bitsPerElement-1);
}