public void PushBack(T1 back) { if (this._end == this._last) { T1[][] t1Array = new T1[this._segmentCount + 1][]; for (int i = 0; i < this._segmentCount; i++) { t1Array[i] = this._segmentList[i]; } t1Array[this._segmentCount] = new T1[this._segmentSize]; DoubleStack <T1> doubleStack = this; doubleStack._segmentCount = doubleStack._segmentCount + 1; this._segmentList = t1Array; DoubleStack <T1> doubleStack1 = this; doubleStack1._last = doubleStack1._last + this._segmentSize; } T1[] t1Array1 = this._segmentList[this._end / this._segmentSize]; t1Array1[this._end % this._segmentSize] = back; DoubleStack <T1> doubleStack2 = this; doubleStack2._end = doubleStack2._end + 1; DoubleStack <T1> doubleStack3 = this; doubleStack3._size = doubleStack3._size + 1; }
public void PushFront(T1 front) { if (this._start == 0) { T1[][] t1Array = new T1[this._segmentCount + 1][]; for (int i = 0; i < this._segmentCount; i++) { t1Array[i + 1] = this._segmentList[i]; } t1Array[0] = new T1[this._segmentSize]; this._segmentList = t1Array; DoubleStack <T1> doubleStack = this; doubleStack._segmentCount = doubleStack._segmentCount + 1; DoubleStack <T1> doubleStack1 = this; doubleStack1._start = doubleStack1._start + this._segmentSize; DoubleStack <T1> doubleStack2 = this; doubleStack2._end = doubleStack2._end + this._segmentSize; DoubleStack <T1> doubleStack3 = this; doubleStack3._last = doubleStack3._last + this._segmentSize; } DoubleStack <T1> doubleStack4 = this; doubleStack4._start = doubleStack4._start - 1; T1[] t1Array1 = this._segmentList[this._start / this._segmentSize]; t1Array1[this._start % this._segmentSize] = front; DoubleStack <T1> doubleStack5 = this; doubleStack5._size = doubleStack5._size + 1; }
public T1 PopFront() { if (this._size == 0) { throw new InvalidOperationException("The DoubleStack is empty."); } T1[] t1Array = this._segmentList[this._start / this._segmentSize]; int num = this._start % this._segmentSize; T1 t1 = t1Array[num]; t1Array[num] = default(T1); DoubleStack <T1> doubleStack = this; doubleStack._start = doubleStack._start + 1; DoubleStack <T1> doubleStack1 = this; doubleStack1._size = doubleStack1._size - 1; if (this._start >= this._segmentShiftPosition) { T1[] t1Array1 = this._segmentList[0]; for (int i = 0; i < this._segmentCount - 1; i++) { this._segmentList[i] = this._segmentList[i + 1]; } this._segmentList[this._segmentCount - 1] = t1Array1; DoubleStack <T1> doubleStack2 = this; doubleStack2._start = doubleStack2._start - this._segmentSize; DoubleStack <T1> doubleStack3 = this; doubleStack3._end = doubleStack3._end - this._segmentSize; } if (this._size == 0) { this._start = this._segmentSize / 2; this._end = this._start; } return(t1); }
public T1 PopBack() { if (this._size == 0) { throw new InvalidOperationException("The DoubleStack is empty."); } T1[] t1Array = this._segmentList[this._end / this._segmentSize]; int num = this._end % this._segmentSize; T1 t1 = t1Array[num]; t1Array[num] = default(T1); DoubleStack <T1> doubleStack = this; doubleStack._end = doubleStack._end - 1; DoubleStack <T1> doubleStack1 = this; doubleStack1._size = doubleStack1._size - 1; if (this._size == 0) { this._start = this._segmentSize / 2; this._end = this._start; } return(t1); }