Fix issue with the git log
The old code was assuming that the buffer was not going to change, this is not true with the current impl though where the list is shifted and ybase and ydisp need to be compensated for that.
This commit is contained in:
@@ -84,12 +84,16 @@ export class CircularList<T> {
|
||||
this._array[this._getCyclicIndex(this._length)] = value;
|
||||
if (this._length === this.maxLength) {
|
||||
this._startIndex++;
|
||||
if (this._startIndex === this.maxLength) {
|
||||
this._startIndex = 0;
|
||||
}
|
||||
} else {
|
||||
this._length++;
|
||||
}
|
||||
}
|
||||
|
||||
public pop(): T {
|
||||
// TODO: This isn't popping from the array, only returning
|
||||
return this._array[this._getCyclicIndex(this._length-- - 1)];
|
||||
}
|
||||
|
||||
@@ -118,6 +122,13 @@ export class CircularList<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public trimStart(count: number): void {
|
||||
// TODO: Error handling
|
||||
// TODO: Testing (if we need this)
|
||||
this._startIndex += count;
|
||||
this._length--;
|
||||
}
|
||||
|
||||
private _getCyclicIndex(index: number): number {
|
||||
return (this._startIndex + index) % this.maxLength;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user