@proficient/ds
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -92,3 +92,3 @@ import type { CharSequenceLike } from '../types'; | ||
* - Time complexity: _O_(_N_ + _S_) | ||
* - Space complexity: _O_(_N_) | ||
* - Space complexity: _O_(1) (amortized) | ||
* | ||
@@ -95,0 +95,0 @@ * where: |
@@ -142,3 +142,3 @@ "use strict"; | ||
* - Time complexity: _O_(_N_ + _S_) | ||
* - Space complexity: _O_(_N_) | ||
* - Space complexity: _O_(1) (amortized) | ||
* | ||
@@ -155,15 +155,12 @@ * where: | ||
const newSeqChars = __classPrivateFieldGet(this, _StringBuilder_instances, "m", _StringBuilder_getCharsOf).call(this, seq); | ||
const chars = new Array(__classPrivateFieldGet(this, _StringBuilder_chars, "f").length + newSeqChars.length); | ||
for (let i = 0; i < chars.length; i++) { | ||
if (i < index) { | ||
chars[i] = __classPrivateFieldGet(this, _StringBuilder_chars, "f")[i]; | ||
} | ||
else if (i >= index && i < index + newSeqChars.length) { | ||
chars[i] = newSeqChars[i - index]; | ||
} | ||
else { | ||
chars[i] = __classPrivateFieldGet(this, _StringBuilder_chars, "f")[i - newSeqChars.length]; | ||
} | ||
// Resize the chars array | ||
__classPrivateFieldGet(this, _StringBuilder_chars, "f")[this.count + newSeqChars.length - 1] = ''; | ||
// Shift every char at i >= index to the right by newSeqChars.length | ||
for (let i = this.count - newSeqChars.length - 1; i >= index; i--) { | ||
__classPrivateFieldGet(this, _StringBuilder_chars, "f")[i + newSeqChars.length] = __classPrivateFieldGet(this, _StringBuilder_chars, "f")[i]; | ||
} | ||
__classPrivateFieldSet(this, _StringBuilder_chars, chars, "f"); | ||
// Add each new char to the appropriate location | ||
for (let i = index; i < index + newSeqChars.length; i++) { | ||
__classPrivateFieldGet(this, _StringBuilder_chars, "f")[i] = newSeqChars[i - index]; | ||
} | ||
return this; | ||
@@ -170,0 +167,0 @@ } |
{ | ||
"name": "@proficient/ds", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "High-quality and essential Typescript data structures", | ||
@@ -40,3 +40,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "0b254c972f9ecd05eebe6af3af2614f6c3f90f84" | ||
"gitHead": "3e0ebb3d12fea0d522c73745c216514462f37bb9" | ||
} |
Sorry, the diff of this file is not supported yet
51059
979