示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IndexableSet{T}"/> class.
        /// </summary>
        /// <param name="capacity">The capacity.</param>
        public IndexableSet(int capacity)
        {
            Ensure.ArgumentInRange(() => capacity >= 0, "capacity", capacity);

            this._hashset = new HashSet <T>();
            this._array   = new DynamicArray <T>(capacity);
        }
 public KeyedQueue(int capacity, Func <T, TKey> keyProvider, bool strictSet)
 {
     Ensure.ArgumentInRange(() => capacity >= 0, "capacity", capacity, null);
     this._hashset     = new HashSet <TKey>();
     this._queue       = new SimpleQueue <T>(capacity);
     this._keyProvider = keyProvider;
     this._strictSet   = strictSet;
 }
 public virtual T[] Allocate(long size)
 {
     Ensure.ArgumentInRange(size, new Range <long>(0, int.MaxValue));
     if (size == 0)
     {
         return(Empty);
     }
     return(_pool.GetOrDefault((int)size)?.PopOrDefault() ?? new T[size]);
 }
示例#4
0
文件: AIMemory.cs 项目: zimpzon/GFun
        /// <summary>
        /// Removes the observation at the supplied index.
        /// </summary>
        /// <param name="index">The index to remove the observation at.</param>
        public void RemoveObservationAt(int index)
        {
            Ensure.ArgumentInRange(() => index >= 0 && index < _observations.Count, "index", index);

            _observations.RemoveAt(index);
        }