/// <summary> /// Stores a value. Will not replace a stored value with an older one. /// </summary> public bool Store(T value) { int index = this.TickToIndex(value.Tick); bool store = false; if (this.latestIdx < 0) { store = true; } else { T latest = this.data[this.latestIdx]; if (value.Tick >= latest.Tick) { store = true; } } if (store) { RailPool.SafeReplace(ref this.data[index], value); this.latestIdx = index; } return(store); }
/// <summary> /// Clears the buffer, freeing all contents. /// </summary> public void Clear() { for (int i = 0; i < this.data.Length; i++) { RailPool.SafeReplace(ref this.data[i], null); } this.latestIdx = -1; }