예제 #1
0
 /**
  * Grow the internal array as needed to accommodate the specified number of elements. The size of
  * the array bytes on each resize unless capacity requires more than twice the current capacity.
  */
 public void ensureCapacity(int capacity) {
   if (capacity > _data.length) {
     int newCap = Math.max(_data.length << 1, capacity);
     byte[] tmp = new byte[newCap];
     System.arraycopy(_data, 0, tmp, 0, _data.length);
     _data = tmp;
   }
 }
예제 #2
0
 /**
  * Creates a new <code>TShortHashSet</code> instance that is a copy of the existing set.
  *
  * @param collection a <tt>TShortSet</tt> that will be duplicated.
  */
 public TShortHashSet(TShortCollection collection) {
   this(Math.max(collection.size(), DEFAULT_CAPACITY));
   if (collection instanceof TShortHashSet) {
     TShortHashSet hashset = (TShortHashSet) collection;
     this._loadFactor = hashset._loadFactor;
     this.no_entry_value = hashset.no_entry_value;
     //noinspection RedundantCast
     if (this.no_entry_value != (short) 0) {
       Arrays.fill(_set, this.no_entry_value);
     }
     setUp((int) Math.ceil(DEFAULT_CAPACITY / _loadFactor));
   }
   addAll(collection);
 }
예제 #3
0
 /**
  * Creates a new <code>TShortHashSet</code> instance that is a copy of the existing Collection.
  *
  * @param collection a <tt>Collection</tt> that will be duplicated.
  */
 public TShortHashSet(Collection<? extends Short> collection) {
   this(Math.max(collection.size(), DEFAULT_CAPACITY));
   addAll(collection);
 }
예제 #4
0
 /**
  * Creates a new <code>TShortHashSet</code> instance containing the elements of <tt>array</tt>.
  *
  * @param array an array of <code>short</code> primitives
  */
 public TShortHashSet(short[] array) {
   this(Math.max(array.length, DEFAULT_CAPACITY));
   addAll(array);
 }