remove on Java 9 and replace with Stream.iterate
488546
private static <T> Stream<T> generateStream(T seed, Predicate<? super T> hasNext, UnaryOperator<T> next) {
        final Spliterator<T> spliterator = Spliterators.spliteratorUnknownSize(new Iterator<T>() {
            private T last = seed;

            @Override
            public boolean hasNext() {
                return hasNext.test(last);
            }

            @Override
            public T next() {
                final T current = last;
                last = next.apply(last);
                return current;
            }
        }, Spliterator.ORDERED);

        return StreamSupport.stream(spliterator, false);
    }
256108
public int replace(Object dependency, ValueSet valueSet) {
        int returnCode = HTODDynacache.NO_EXCEPTION;
        dependencyNotUpdatedTable.remove(dependency);
        if (valueSet != null && valueSet.size() > this.delayOffloadEntriesLimit) {
            dependencyToEntryTable.remove(dependency);
            if (this.type == DEP_ID_TABLE) {
                returnCode = this.htod.writeValueSet(HTODDynacache.DEP_ID_DATA, dependency, valueSet, HTODDynacache.ALL);  // valueSet may be empty after writeValueSet
                this.htod.cache.getCacheStatisticsListener().depIdsOffloadedToDisk(dependency);
                //System.out.println("***** replace dependency id=" + dependency + " size=" + valueSet.size());
            } else {
                returnCode = this.htod.writeValueSet(HTODDynacache.TEMPLATE_ID_DATA, dependency, valueSet, HTODDynacache.ALL);  // valueSet may be empty after writeValueSet
                this.htod.cache.getCacheStatisticsListener().templatesOffloadedToDisk(dependency);
                //System.out.println("***** replace template id=" + dependency + " size=" + valueSet.size());
            }
        } else {
            if (valueSet.size() > 0) {
                dependencyToEntryTable.put(dependency, valueSet);
            } else {
                dependencyToEntryTable.remove(dependency);
            }
        }
        if (returnCode == HTODDynacache.DISK_SIZE_OVER_LIMIT_EXCEPTION && valueSet.size() > 0) {
            this.htod.delCacheEntry(valueSet, CachePerf.DISK_OVERFLOW, CachePerf.LOCAL, 
                                    !Cache.FROM_DEPID_TEMPLATE_INVALIDATION, 
                                    HTODInvalidationBuffer.FIRE_EVENT);
            returnCode = HTODDynacache.NO_EXCEPTION;
        }
        return returnCode;
    }
388098
public final long replace(String pid, InputStream content)
            throws LowlevelStorageException {
        File file = getFile(pid);
        fileSystem.rewrite(file, content);
        return file.length();
    }
518575
def remove_each(text, items, count=None, strip=False):
    '''
    
    '''
    for item in items:
        text = remove(text, item, count=count, strip=strip)
    return text
1045584
function stringifyReplacerArr (key, value, stack, replacer) {
  var i, res
  // If the value has a toJSON method, call it to obtain a replacement value.
  if (typeof value === 'object' && value !== null && typeof value.toJSON === 'function') {
    value = value.toJSON(key)
  }

  switch (typeof value) {
    case 'object':
      if (value === null) {
        return 'null'
      }
      for (i = 0; i < stack.length; i++) {
        if (stack[i] === value) {
          return '"[Circular]"'
        }
      }
      if (Array.isArray(value)) {
        if (value.length === 0) {
          return '[]'
        }
        stack.push(value)
        res = '['
        // Use null as placeholder for non-JSON values.
        for (i = 0; i < value.length - 1; i++) {
          const tmp = stringifyReplacerArr(i, value[i], stack, replacer)
          res += tmp !== undefined ? tmp : 'null'
          res += ','
        }
        const tmp = stringifyReplacerArr(i, value[i], stack, replacer)
        res += tmp !== undefined ? tmp : 'null'
        res += ']'
        stack.pop()
        return res
      }

      if (replacer.length === 0) {
        return '{}'
      }
      stack.push(value)
      res = '{'
      var separator = ''
      for (i = 0; i < replacer.length; i++) {
        if (typeof replacer[i] === 'string' || typeof replacer[i] === 'number') {
          key = replacer[i]
          const tmp = stringifyReplacerArr(key, value[key], stack, replacer)
          if (tmp !== undefined) {
            res += `${separator}"${strEscape(key)}":${tmp}`
            separator = ','
          }
        }
      }
      res += '}'
      stack.pop()
      return res
    case 'string':
      return `"${strEscape(value)}"`
    case 'number':
      // JSON numbers must be finite. Encode non-finite numbers as null.
      return isFinite(value) ? String(value) : 'null'
    case 'boolean':
      return value === true ? 'true' : 'false'
  }
}
848440
@Override
  public boolean replaceFailure(K key, V value, V newValue, StoreAccessException e) {
    cleanup(key, e);
    return false;
  }
916797
function destroy (stream) {
  if (stream instanceof ReadStream) {
    return destroyReadStream(stream)
  }

  if (!(stream instanceof Stream)) {
    return stream
  }

  if (typeof stream.destroy === 'function') {
    stream.destroy()
  }

  return stream
}
277388
@Override
  public boolean replace    ( TypeK  key, TypeV  oldValue, TypeV newValue ) {
    return Objects.equals(putIfMatch( key, newValue, oldValue ), oldValue);
  }
909080
def _recurse_replace(obj, key, new_key, sub, remove):
    """"""
    if isinstance(obj, list):
        return [_recurse_replace(x, key, new_key, sub, remove) for x in obj]
    if isinstance(obj, dict):
        for k, v in list(obj.items()):
            if k == key and v in sub:
                obj[new_key] = sub[v]
                if remove:
                    del obj[key]
            else:
                obj[k] = _recurse_replace(v, key, new_key, sub, remove)
    return obj
920682
def mutate_stream (instream, outstream):
    """"""

    chunk = None
    key = None
    data = None
    misclines = []

    for fullline in instream:
        line = fullline.split ('#', 1)[0]

        m = sectionre.match (line)
        if m is not None:
            # New chunk
            if chunk is not None:
                if key is not None:
                    chunk.data.set_one (key, data.strip ().decode ('utf8'))
                    key = data = None
                yield chunk
                chunk.emit (outstream)

            chunk = FileChunk ()
            for miscline in misclines:
                chunk._addLine (miscline, None)
            misclines = []
            chunk.data.section = m.group (1)
            chunk._addLine (fullline, None)
            continue

        if len (line.strip ()) == 0:
            if key is not None:
                chunk.data.set_one (key, data.strip ().decode ('utf8'))
                key = data = None
            if chunk is not None:
                chunk._addLine (fullline, None)
            else:
                misclines.append (fullline)
            continue

        m = escre.match (fullline)
        if m is not None:
            if chunk is None:
                raise InifileError ('key seen without section!')
            if key is not None:
                chunk.data.set_one (key, data.strip ().decode ('utf8'))
            key = m.group (1)
            data = m.group (2).replace (r'\"', '"').replace (r'\n', '\n').replace (r'\\', '\\')
            chunk.data.set_one (key, data.decode ('utf8'))
            chunk._addLine (fullline, key)
            key = data = None
            continue

        m = keyre.match (line)
        if m is not None:
            if chunk is None:
                raise InifileError ('key seen without section!')
            if key is not None:
                chunk.data.set_one (key, data.strip ().decode ('utf8'))
            key = m.group (1)
            data = m.group (2)
            if not data[-1].isspace ():
                data += ' '
            chunk._addLine (fullline, key)
            continue

        if line[0].isspace () and key is not None:
            data += line.strip () + ' '
            chunk._addLine (fullline, key)
            continue

        raise InifileError ('unparsable line: ' + line[:-1])

    if chunk is not None:
        if key is not None:
            chunk.data.set_one (key, data.strip ().decode ('utf8'))
        yield chunk
        chunk.emit (outstream)
356709
public void replaceBy(Map<? extends K, ? extends V> data) {
        Map<K, V> d = copy();
        d.clear();
        d.putAll(data);
        update(d);
    }
161943
def purge_stream(self, stream_id, remove_definition=False, sandbox=None):
        
        super(AssetsChannel, self).purge_stream(
            stream_id=stream_id, remove_definition=remove_definition, sandbox=sandbox)
218043
@Override
	public int replace(int handle, Object obj) throws DataStoreException
    {
        if (SAFE_MODE) checkHandle(handle);
    	data[handle] = obj;
    	return handle;
    }
1149771
@Nullable
  static <T> T removeFirstMatching(Iterable<T> removeFrom, Predicate<? super T> predicate) {
    checkNotNull(predicate);
    Iterator<T> iterator = removeFrom.iterator();
    while (iterator.hasNext()) {
      T next = iterator.next();
      if (predicate.apply(next)) {
        iterator.remove();
        return next;
      }
    }
    return null;
  }
506805
public static <T, P> boolean removeIfWith(
            Iterable<T> iterable,
            Predicate2<? super T, ? super P> predicate,
            P parameter)
    {
        if (iterable instanceof MutableCollection)
        {
            return ((MutableCollection<T>) iterable).removeIfWith(predicate, parameter);
        }
        if (iterable instanceof ArrayList)
        {
            return ArrayListIterate.removeIfWith((ArrayList<T>) iterable, predicate, parameter);
        }
        if (iterable instanceof List)
        {
            return ListIterate.removeIfWith((List<T>) iterable, predicate, parameter);
        }
        if (iterable != null)
        {
            return IterableIterate.removeIfWith(iterable, predicate, parameter);
        }
        throw new IllegalArgumentException("Cannot perform a remove on null");
    }
112206
@Override
    public String replace(InputStream in, String flickrId, boolean async) throws FlickrException {
        Payload payload = new Payload(in, flickrId);
        return sendReplaceRequest(async, payload);
    }
419944
def remove(cls, name):
        

        api = Client.instance().api

        api.collection(name).delete()