Example #1
0
        public void Move(int oldindex, int newindex)
        {
            T item;

            lock (locker) {
                item             = intern[oldindex];
                status[oldindex] = false;

                while (newindex >= intern.Count)
                {
                    intern.Add(default(T));
                }

                if (status[newindex] == true)
                {
                    var olditem = intern[newindex];

                    ItemRemoved?.Invoke(olditem);
                    ItemWithdrawn?.Invoke(olditem, newindex);
                }
                else
                {
                    status[newindex] = true;
                }

                intern[newindex] = item;
            }

            ItemMoved?.Invoke(item, oldindex, newindex);
        }
Example #2
0
        public void RemoveAt(int index)
        {
            T item;

            lock (locker) {
                item = intern[index];
                intern.RemoveAt(index);
                status.Withdraw(index);
            }

            ItemRemoved?.Invoke(item);
            ItemWithdrawn?.Invoke(item, index);

            for (int j = index; j < intern.Count; j++)
            {
                ItemMoved(intern[j], j, j - 1);
            }
        }
Example #3
0
        public void Clear()
        {
            T[] items;

            lock (locker) {
                items = intern.ToArray();
                intern.Clear();
                status.Clear();
            }

            for (int i = items.Length - 1; i >= 0; i--)
            {
                var item = items[i];

                ItemRemoved?.Invoke(item);
                ItemWithdrawn?.Invoke(item, i);
            }
        }