Exemplo n.º 1
0
 /**
  * Returns a clone of this list. Since this is a primitive collection, this will be a deep clone.
  *
  * @return a deep clone of the list.
  */
 public Object clone() {
   LongSequence list = null;
   try {
     list = (LongSequence) super.clone();
     list.data = toNativeArray();
   } catch (CloneNotSupportedException e) {
     // it's supported
   } // end get try-catch
   return list;
 }
Exemplo n.º 2
0
 /**
  * Returns a sublist of this list.
  *
  * @param begin low endpoint (inclusive) of the subList.
  * @param end high endpoint (exclusive) of the subList.
  * @return sublist of this list from begin, inclusive to end, exclusive.
  * @throws IndexOutOfBoundsException - endpoint out of range
  * @throws IllegalArgumentException - endpoints out of order (end > begin)
  */
 public LongSequence subList(int begin, int end) {
   if (end < begin)
     throw new IllegalArgumentException("end index " + end + " greater than begin index " + begin);
   if (begin < 0) throw new IndexOutOfBoundsException("begin index can not be < 0");
   if (end > data.length) throw new IndexOutOfBoundsException("end index < " + data.length);
   LongSequence list = new LongSequence(end - begin);
   for (int i = begin; i < end; i++) {
     list.add(data[i]);
   }
   return list;
 }
Exemplo n.º 3
0
 /**
  * Compares this list to another list, value by value.
  *
  * @param other the object to compare against
  * @return true if other is a LongArrayList and has exactly the same values.
  */
 @Override
 public boolean equals(Object other) {
   if (other == this) {
     return true;
   } else if (other instanceof LongSequence) {
     LongSequence that = (LongSequence) other;
     if (that.size() != this.size()) {
       return false;
     } else {
       for (int i = pos; i-- > 0; ) {
         if (this.data[i] != that.data[i]) {
           return false;
         }
       }
       return true;
     }
   } else {
     return false;
   }
 }
Exemplo n.º 4
0
 public static LongSequence from(long... array) {
   LongSequence seq = new LongSequence(0);
   seq.data = array;
   seq.pos = array.length;
   return seq;
 }