Exemplo n.º 1
0
        public FasterList(FasterList <T> listCopy)
        {
            _buffer = new T[listCopy.Count];

            listCopy.CopyTo(_buffer, 0);

            _count = listCopy.Count;
        }
Exemplo n.º 2
0
        public FasterReadOnlyList(FasterList <T> list)
        {
            _list = list;

            int count;

            _buffer = FasterList <T> .NoVirt.ToArrayFast(list, out count);
        }
Exemplo n.º 3
0
 public FasterListThreadSafe(FasterList <T> list)
 {
     if (list == null)
     {
         throw new ArgumentException("invalid list");
     }
     _list  = list;
     _lockQ = new ReaderWriterLockSlim();
 }
Exemplo n.º 4
0
 public ThreadSafeFasterList(FasterList <T> list)
 {
     if (list == null)
     {
         throw new ArgumentException("invalid list");
     }
     _list  = list;
     _lockQ = ReaderWriterLockSlimEx.Create();
 }
Exemplo n.º 5
0
        public void AddRange(FasterList <T> items)
        {
            var count = items.Count;

            if (_count + count >= _buffer.Length)
            {
                AllocateMore(_count + count);
            }

            Array.Copy(items._buffer, 0, _buffer, _count, count);
            _count += count;
        }
Exemplo n.º 6
0
        /// <summary>
        /// this is a dirtish trick to be able to use the index operator
        /// before adding the elements through the Add functions
        /// </summary>
        /// <typeparam name="U"></typeparam>
        /// <param name="initialSize"></param>
        /// <returns></returns>
        public static FasterList <T> PreFill <U>(int initialSize) where U : class, T, new()
        {
            var list = new FasterList <T>(initialSize);

            var listCount = list._count;

            for (int i = 0; i < initialSize; i++)
            {
                list[listCount + i] = new U();
            }

            return(list);
        }
Exemplo n.º 7
0
        public static FasterList <T> PreFill <U>(int initialSize) where U : T, new()
        {
            var list = new FasterList <T>(initialSize);

            for (int i = 0; i < initialSize; i++)
            {
                list.Add(new U());
            }

            list.Clear();

            return(list);
        }
Exemplo n.º 8
0
 public void DequeueInto(FasterList <T> list, int count)
 {
     _lockQ.EnterWriteLock();
     try
     {
         int originalSize = _queue.Count;
         while (_queue.Count > 0 && originalSize - _queue.Count < count)
         {
             list.Add(_queue.Dequeue());
         }
     }
     finally
     {
         _lockQ.ExitWriteLock();
     }
 }
Exemplo n.º 9
0
        public void DequeueAllInto(FasterList <T> list)
        {
            LockQ.EnterWriteLock();
            try
            {
                while (m_Queue.Count > 0)
                {
                    list.Add(m_Queue.Dequeue());
                }
            }

            finally
            {
                LockQ.ExitWriteLock();
            }
        }
Exemplo n.º 10
0
        public FasterList <T> DequeueAll()
        {
            FasterList <T> returnList = new FasterList <T>(_queue.Count);

            _lockQ.EnterWriteLock();
            try
            {
                while (_queue.Count > 0)
                {
                    returnList.Add(_queue.Dequeue());
                }

                return(returnList);
            }
            finally
            {
                _lockQ.ExitWriteLock();
            }
        }
Exemplo n.º 11
0
        public FasterList <U> DequeueAllAs <U>() where U : class
        {
            FasterList <U> returnList = new FasterList <U>();

            _lockQ.EnterWriteLock();
            try
            {
                while (_queue.Count > 0)
                {
                    returnList.Add(_queue.Dequeue() as U);
                }

                return(returnList);
            }
            finally
            {
                _lockQ.ExitWriteLock();
            }
        }
Exemplo n.º 12
0
        public void DequeueAllInto(FasterList <T> list)
        {
            int i = list.Count;

            list.ExpandBy((uint)_queue.Count);

            var array = list.ToArrayFast();

            _lockQ.EnterWriteLock();
            try
            {
                while (_queue.Count > 0)
                {
                    array[i++] = _queue.Dequeue();
                }
            }
            finally
            {
                _lockQ.ExitWriteLock();
            }
        }
Exemplo n.º 13
0
        public void DequeueAllInto(FasterList <T> list)
        {
            LockQ.EnterWriteLock();
            try
            {
                int i = list.Count;

                list.GrowAndSetCount(m_Queue.Count);

                var array = list.ToArrayFast();

                while (m_Queue.Count > 0)
                {
                    array[i++] = m_Queue.Dequeue();
                }
            }

            finally
            {
                LockQ.ExitWriteLock();
            }
        }
Exemplo n.º 14
0
 public ThreadSafeFasterList()
 {
     _list  = new FasterList <T>();
     _lockQ = ReaderWriterLockSlimEx.Create();
 }
Exemplo n.º 15
0
 public void AddRange(FasterList <T> items)
 {
     AddRange(items.ToArrayFast(), items.Count);
 }
Exemplo n.º 16
0
 public FasterListThreadSafe()
 {
     _list  = new FasterList <T>();
     _lockQ = new ReaderWriterLockSlim();
 }
Exemplo n.º 17
0
 public static void FastSet(FasterList <T> fasterList, int index, T item)
 {
     fasterList._buffer[index] = item;
     fasterList._count         = index + 1;
 }
Exemplo n.º 18
0
 public HeapPriorityQueue(int initialSize)
 {
     _numNodes             = 0;
     _nodes                = new FasterList <T>(initialSize);
     _numNodesEverEnqueued = 0;
 }
Exemplo n.º 19
0
 /// <summary>
 /// Instantiate a new Priority Queue
 /// </summary>
 /// <param name="maxNodes">The max nodes ever allowed to be enqueued (going over this will cause an exception)</param>
 public HeapPriorityQueue()
 {
     _numNodes             = 0;
     _nodes                = new FasterList <T>();
     _numNodesEverEnqueued = 0;
 }
Exemplo n.º 20
0
 internal FasterSparseList(FasterDenseList <T> denseSet)
 {
     _denseSet = denseSet;
     _keys     = new FasterList <uint>();
 }
Exemplo n.º 21
0
            public static T[] ToArrayFast(FasterList <T> fasterList, out int count)
            {
                count = fasterList._count;

                return(fasterList._buffer);
            }
Exemplo n.º 22
0
 public static int Count(FasterList <T> fasterList)
 {
     return(fasterList._count);
 }
Exemplo n.º 23
0
 public void CopyValuesTo(FasterList <TValue> values)
 {
     values.ExpandTo((uint)_dict.count);
     CopyValuesTo(values.ToArrayFast(out _), 0);
 }
Exemplo n.º 24
0
 public FasterListThreadSafe(FasterList <T> list)
 {
     _list  = list;
     _lockQ = new ReaderWriterLockSlim();
 }
Exemplo n.º 25
0
 public FasterDenseList()
 {
     values = new FasterList <T>();
 }
Exemplo n.º 26
0
 public ThreadSafeQueue()
 {
     _queue = new FasterList <T>(1);
 }
 public void CopyTo(FasterList <TValue> transientEntitiesOperations)
 {
     transientEntitiesOperations.ExpandTo(_dict.count);
     CopyTo(transientEntitiesOperations.ToArrayFast());
 }
Exemplo n.º 28
0
 internal static T[] ToArrayFast(FasterList <T> fasterList)
 {
     return(fasterList._buffer);
 }
Exemplo n.º 29
0
 public FasterReadOnlyList(FasterList <T> list)
 {
     _list = list;
 }
Exemplo n.º 30
0
 public ThreadSafeQueue(int capacity)
 {
     _queue = new FasterList <T>(capacity);
 }