public void pushFront(T val) { Contract.Assert(size < capacity); head_ = head_ - 1; size_ += 1; buff_ [head_.value] = val; }
public CircularBuffer(int capacity) { capacity_ = capacity; head_ = new ModularInt(0, capacity_); size_ = 0; buff_ = new T[capacity_]; }
public T popFront() { Contract.Assert(size > 0); var index = head_; head_ = head_ + 1; size_ -= 1; return(buff_ [index.value]); }