예제 #1
0
        /// <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);
        }
예제 #2
0
 /// <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;
 }