예제 #1
0
        public FasterList(FasterList <T> listCopy)
        {
            _buffer = new T[listCopy.Count];

            listCopy.CopyTo(_buffer, 0);

            _count = listCopy.Count;
        }
예제 #2
0
        public FasterReadOnlyList(FasterList <T> list)
        {
            _list = list;

            int count;

            _buffer = FasterList <T> .NoVirt.ToArrayFast(list, out count);
        }
예제 #3
0
파일: FasterList.cs 프로젝트: Hengle/otiose
 public FasterListThreadSafe(FasterList <T> list)
 {
     if (list == null)
     {
         throw new ArgumentException("invalid list");
     }
     _list  = list;
     _lockQ = new ReaderWriterLockSlim();
 }
예제 #4
0
 public ThreadSafeFasterList(FasterList <T> list)
 {
     if (list == null)
     {
         throw new ArgumentException("invalid list");
     }
     _list  = list;
     _lockQ = ReaderWriterLockSlimEx.Create();
 }
예제 #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;
        }
예제 #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);
        }
예제 #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);
        }
예제 #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();
     }
 }
예제 #9
0
        public void DequeueAllInto(FasterList <T> list)
        {
            LockQ.EnterWriteLock();
            try
            {
                while (m_Queue.Count > 0)
                {
                    list.Add(m_Queue.Dequeue());
                }
            }

            finally
            {
                LockQ.ExitWriteLock();
            }
        }
예제 #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();
            }
        }
예제 #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();
            }
        }
예제 #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();
            }
        }
예제 #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();
            }
        }
예제 #14
0
 public ThreadSafeFasterList()
 {
     _list  = new FasterList <T>();
     _lockQ = ReaderWriterLockSlimEx.Create();
 }
예제 #15
0
 public void AddRange(FasterList <T> items)
 {
     AddRange(items.ToArrayFast(), items.Count);
 }
예제 #16
0
 public FasterListThreadSafe()
 {
     _list  = new FasterList <T>();
     _lockQ = new ReaderWriterLockSlim();
 }
예제 #17
0
 public static void FastSet(FasterList <T> fasterList, int index, T item)
 {
     fasterList._buffer[index] = item;
     fasterList._count         = index + 1;
 }
예제 #18
0
 public HeapPriorityQueue(int initialSize)
 {
     _numNodes             = 0;
     _nodes                = new FasterList <T>(initialSize);
     _numNodesEverEnqueued = 0;
 }
예제 #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;
 }
예제 #20
0
 internal FasterSparseList(FasterDenseList <T> denseSet)
 {
     _denseSet = denseSet;
     _keys     = new FasterList <uint>();
 }
예제 #21
0
파일: FasterList.cs 프로젝트: Hengle/otiose
            public static T[] ToArrayFast(FasterList <T> fasterList, out int count)
            {
                count = fasterList._count;

                return(fasterList._buffer);
            }
예제 #22
0
파일: FasterList.cs 프로젝트: Hengle/otiose
 public static int Count(FasterList <T> fasterList)
 {
     return(fasterList._count);
 }
예제 #23
0
 public void CopyValuesTo(FasterList <TValue> values)
 {
     values.ExpandTo((uint)_dict.count);
     CopyValuesTo(values.ToArrayFast(out _), 0);
 }
예제 #24
0
 public FasterListThreadSafe(FasterList <T> list)
 {
     _list  = list;
     _lockQ = new ReaderWriterLockSlim();
 }
예제 #25
0
 public FasterDenseList()
 {
     values = new FasterList <T>();
 }
예제 #26
0
 public ThreadSafeQueue()
 {
     _queue = new FasterList <T>(1);
 }
 public void CopyTo(FasterList <TValue> transientEntitiesOperations)
 {
     transientEntitiesOperations.ExpandTo(_dict.count);
     CopyTo(transientEntitiesOperations.ToArrayFast());
 }
예제 #28
0
파일: FasterList.cs 프로젝트: Hengle/otiose
 internal static T[] ToArrayFast(FasterList <T> fasterList)
 {
     return(fasterList._buffer);
 }
예제 #29
0
 public FasterReadOnlyList(FasterList <T> list)
 {
     _list = list;
 }
예제 #30
0
 public ThreadSafeQueue(int capacity)
 {
     _queue = new FasterList <T>(capacity);
 }