Remove any index with the same indexKey but differing indexOptions in anticipation of recreating it.

@param collection The collection to check the indexes of
@param index      The index to find
348876
private static void removeDifferingIndexIfAny(final MongoCollection collection, final Index index) {
        val indexes = (ListIndexesIterable<Document>) collection.listIndexes();
        var indexExistsWithDifferentOptions = false;

        for (val existingIndex : indexes) {
            val keyMatches = existingIndex.get("key").equals(index.getIndexKeys());
            val optionsMatch = index.getIndexOptions().entrySet().stream().allMatch(entry -> entry.getValue().equals(existingIndex.get(entry.getKey())));
            val noExtraOptions = existingIndex.keySet().stream().allMatch(key -> MONGO_INDEX_KEYS.contains(key) || index.getIndexOptions().keySet().contains(key));
            indexExistsWithDifferentOptions |= keyMatches && !(optionsMatch && noExtraOptions);
        }

        if (indexExistsWithDifferentOptions) {
            LOGGER.debug("Removing MongoDb index [{}] from [{}] because it appears to already exist in a different form", index.getIndexKeys(), collection.getNamespace());
            collection.dropIndex(index.getIndexKeys());
        }
    }
637631
private void remove(int index) {
        int lastIndex = --size;
        Reference<E> removed = storage.array[index];
        Reference<E> lastElem = storage.array[lastIndex];
        storage.array[index] = lastElem;
        lastElem.index = index;
        removed.index = -1;
        storage.array[lastIndex] = null;
    }
780542
public void invalidate(InternalIndex index) {
        String[] components = index.getComponents();
        if (components == null) {
            cache.remove(index.getName());
            return;
        }

        for (String component : components) {
            TypeConverter converter = cache.get(component);
            if (converter instanceof UnresolvedConverter) {
                cache.remove(component);
            }
        }
    }
1072424
private void removeAllEntries() {
        // A bit unusual, but we want to make sure we do not call this while the index is active.
        Preconditions.checkState(this.closed, "Cannot call removeAllEntries unless the ReadIndex is closed.");
        int count;
        synchronized (this.lock) {
            this.indexEntries.forEach(entry -> {
                if (entry.isDataEntry()) {
                    CacheKey key = getCacheKey(entry);
                    this.cache.remove(key);
                }
            });

            count = this.indexEntries.size();
            this.indexEntries.clear();
        }

        if (count > 0) {
            log.debug("{}: Cleared all cache entries ({}).", this.traceObjectId, count);
        }
    }
250233
public void clear(int index) {
        if(index < 0 || index >= size)
            throw new IndexOutOfBoundsException("index: " + index);

        int wordIndex=wordIndex(index);
        words[wordIndex]&=~(1L << index);
    }
119767
public E remove (int index) {
		E e = data[index]; // make copy of element to remove so it can be returned
		data[index] = data[--size]; // overwrite item to remove with last element
		data[size] = null; // null last element, so gc can do its work
		return e;
	}
1027902
public void removeVertex(int index) {
        this.cornerX.remove(index);
        this.cornerY.remove(index);
        this.cornerZ.remove(index);
        if (isGradation() == true) this.cornerColor.remove(index);
        setNumberOfCorner(this.cornerX.size());
        calcG();
    }
67146
void remove_document(int index)
    {
        ListIterator<Document<K>> listIterator = documents_.listIterator(index);
        Document<K> document = listIterator.next();
        listIterator.set(null);
        composite_.sub_vector(document.feature());
    }
1360222
public boolean removeBusHalt(int index) {
		try {
			final BusItineraryHalt removedBushalt;
			if (index < this.validHalts.size()) {
				removedBushalt = this.validHalts.remove(index);
			} else {
				final int idx = index - this.validHalts.size();
				removedBushalt = this.invalidHalts.remove(idx);
			}
			removedBushalt.setContainer(null);
			removedBushalt.setRoadSegmentIndex(-1);
			removedBushalt.setPositionOnSegment(Float.NaN);
			removedBushalt.setEventFirable(true);
			removedBushalt.checkPrimitiveValidity();
			fireShapeChanged(new BusChangeEvent(this,
					BusChangeEventType.ITINERARY_HALT_REMOVED,
					removedBushalt,
					removedBushalt.indexInParent(),
					"shape", //$NON-NLS-1$
					null,
					null));
			checkPrimitiveValidity();
			return true;
		} catch (Throwable exception) {
			//
		}
		return false;
	}
294256
public void remove( int idx ) 
    {
        if ( idx < 0 || idx > size )
            throw new IndexOutOfBoundsException();
        int numMove = size - idx - 1;
        if ( numMove > 0 )
            System.arraycopy(items, idx + 1, items, idx, numMove);
        size--;
    }
120879
public JsonElement remove(int index) {
        checkIfFrozen();
        if (index < 0 || index >= values.size()) {
            return null;
        }
        return values.remove(index);
    }
111227
@Override
    public void delete(int index)
    {
        checkNotSealed(null, index);
        slotMap.remove(null, index);
    }
1149738
public static Object remove(Object array, int index) {
        int length = length(array);
        if (index < 0 || index >= length) {
            throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + length);
        }

        Object result = Array.newInstance(array.getClass().getComponentType(), length - 1);
        System.arraycopy(array, 0, result, 0, index);
        if (index < length - 1) {
            System.arraycopy(array, index + 1, result, index, length - index - 1);
        }

        return result;
    }
240200
public boolean remove(int index) {

        Widget w = getWidget(index);
        if (w != null) {
            return remove(getWidget(index));
        }
        return false;
    }
857539
private void remove(Integer layer, Refreshable refreshable)
    {
        final Collection<Refreshable> refreshables = getLayer(layer);
        refreshables.remove(refreshable);
        if (refreshables.isEmpty())
        {
            indexs.remove(layer);
        }
    }
648239
public void removeConnective( int index ) {

        if ( this.connectives == null ) {
            return;
        }
        if ( index < 0 || index > connectives.length ) {
            throw new IndexOutOfBoundsException();
        }
        int newIndex = 0;
        final ConnectiveConstraint[] newList = new ConnectiveConstraint[ this.connectives.length - 1 ];
        for ( int i = 0; i < this.connectives.length; i++ ) {
            if ( i != index ) {
                newList[ newIndex++ ] = this.connectives[ i ];
            }
        }
        this.connectives = newList;
    }
1253355
private void deleteFromIndices(ApiType oldObj, String key) {
    for (Map.Entry<String, Function<ApiType, List<String>>> indexEntry : this.indexers.entrySet()) {
      Function<ApiType, List<String>> indexFunc = indexEntry.getValue();
      List<String> indexValues = indexFunc.apply(oldObj);
      if (io.kubernetes.client.util.common.Collections.isEmptyCollection(indexValues)) {
        continue;
      }

      Map<String, Set<String>> index = this.indices.get(indexEntry.getKey());
      if (index == null) {
        continue;
      }
      for (String indexValue : indexValues) {
        Set<String> indexSet = index.get(indexValue);
        if (indexSet != null) {
          indexSet.remove(key);
        }
      }
    }
  }