MCPcopy
hub / github.com/tensorflow/tfjs / shuffleExcise

Method shuffleExcise

tfjs-data/src/util/ring_buffer.ts:167–175  ·  view source on GitHub ↗

* Removes and returns a specific item in the buffer, and moves the last item * to the vacated slot. This is useful for implementing a shuffling stream. * Note that this operation necessarily scrambles the original order. * * @param relativeIndex: the index of the item to remove, relativ

(relativeIndex: number)

Source from the content-addressed store, hash-verified

165 * storage).
166 */
167 shuffleExcise(relativeIndex: number): T {
168 if (this.isEmpty()) {
169 throw new RangeError('Ring buffer is empty.');
170 }
171 const index = this.wrap(this.begin + relativeIndex);
172 const result = this.get(index);
173 this.set(index, this.pop());
174 return result;
175 }
176}

Callers 2

serialNextMethod · 0.80

Calls 5

isEmptyMethod · 0.95
wrapMethod · 0.95
getMethod · 0.95
setMethod · 0.95
popMethod · 0.95

Tested by

no test coverage detected