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

Method expand

tfjs-data/src/util/growing_ring_buffer.ts:52–68  ·  view source on GitHub ↗

* Doubles the capacity of the buffer.

()

Source from the content-addressed store, hash-verified

50 * Doubles the capacity of the buffer.
51 */
52 private expand() {
53 const newCapacity = this.capacity * 2;
54 const newData = new Array<T>(newCapacity);
55 const len = this.length();
56
57 // Rotate the buffer to start at index 0 again, since we can't just
58 // allocate more space at the end.
59 for (let i = 0; i < len; i++) {
60 newData[i] = this.get(this.wrap(this.begin + i));
61 }
62
63 this.data = newData;
64 this.capacity = newCapacity;
65 this.doubledCapacity = 2 * this.capacity;
66 this.begin = 0;
67 this.end = len;
68 }
69}

Callers 2

pushMethod · 0.95
unshiftMethod · 0.95

Calls 3

lengthMethod · 0.80
wrapMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected