示例#1
0
 @Override
 public Vector<T> removeAll(T element) {
   HashArrayMappedTrie<Integer, T> result = HashArrayMappedTrie.empty();
   for (int i = 0; i < length(); i++) {
     final T value = get(i);
     if (!element.equals(value)) {
       result = result.put(result.size(), value);
     }
   }
   return result.size() == length() ? this : (result.isEmpty() ? empty() : new Vector<>(result));
 }
示例#2
0
 @Override
 public Array<T> replaceAll(T currentElement, T newElement) {
   final Object[] arr = new Object[length()];
   boolean changed = false;
   for (int i = 0; i < length(); i++) {
     final T value = get(i);
     if (currentElement.equals(value)) {
       arr[i] = newElement;
       changed = true;
     } else {
       arr[i] = get(i);
     }
   }
   return changed ? wrap(arr) : this;
 }
示例#3
0
 @Override
 public Vector<T> replaceAll(T currentElement, T newElement) {
   HashArrayMappedTrie<Integer, T> trie = HashArrayMappedTrie.empty();
   boolean changed = false;
   for (int i = 0; i < length(); i++) {
     final T value = get(i);
     if (currentElement.equals(value)) {
       trie = trie.put(trie.size(), newElement);
       changed = true;
     } else {
       trie = trie.put(trie.size(), value);
     }
   }
   return changed ? (trie.isEmpty() ? empty() : new Vector<>(trie)) : this;
 }
示例#4
0
 @Override
 public Array<T> remove(T element) {
   int index = -1;
   for (int i = 0; i < length(); i++) {
     final T value = get(i);
     if (element.equals(value)) {
       index = i;
       break;
     }
   }
   if (index < 0) {
     return this;
   } else {
     return removeAt(index);
   }
 }
示例#5
0
 @Override
 public Vector<T> remove(T element) {
   HashArrayMappedTrie<Integer, T> trie = HashArrayMappedTrie.empty();
   boolean found = false;
   for (int i = 0; i < length(); i++) {
     final T value = get(i);
     if (found) {
       trie = trie.put(trie.size(), value);
     } else {
       if (element.equals(value)) {
         found = true;
       } else {
         trie = trie.put(trie.size(), value);
       }
     }
   }
   return trie.size() == length() ? this : trie.isEmpty() ? empty() : new Vector<>(trie);
 }
示例#6
0
文件: One.java 项目: ckaestne/varex2
 @Override
 public int hashCode() {
   return value.hashCode();
 }