Example #1
0
 @Override
 public Array<T> slice(long beginIndex, long endIndex) {
   if (beginIndex >= endIndex || beginIndex >= length() || isEmpty()) {
     return empty();
   }
   if (beginIndex <= 0 && endIndex >= length()) {
     return this;
   }
   final int index = Math.max((int) beginIndex, 0);
   final int length = Math.min((int) endIndex, length()) - index;
   final Object[] arr = new Object[length];
   System.arraycopy(delegate, index, arr, 0, length);
   return wrap(arr);
 }
Example #2
0
 Array<T> with(int startIndex, int length) {
   length = Math.min(delegate.length - startIndex, length);
   if (length <= 0) {
     return empty();
   } else {
     return new Array<T>(delegate, startIndex, length);
   }
 }
Example #3
0
 @Override
 public int lastIndexOf(T element, int end) {
   for (int i = Math.min(end, length() - 1); i >= 0; i--) {
     if (Objects.equals(get(i), element)) {
       return i;
     }
   }
   return -1;
 }
Example #4
0
 @Override
 public Array<Array<T>> combinations(int k) {
   return Combinations.apply(this, Math.max(k, 0));
 }