Example #1
0
        public static void RemoveAt <T>(this StorageList list, BigInteger index)
        {
            var size = list.Count();

            if (index < 0 || index >= size)
            {
                throw new StorageException("outside of range");
            }

            var indexKey = ElementKey(list.BaseKey, index);

            size = size - 1;

            if (size > index)
            {
                // TODO <T> would not really be necessary here, this swap could be improved by using byte[]
                var last = list.Get <T>(size);
                list.Replace(index, last);
            }

            var key = ElementKey(list.BaseKey, size);

            list.Context.Delete(key);

            list.Context.Put(CountKey(list.BaseKey), size);
        }
Example #2
0
        public static void Add <T>(this StorageList list, T element)
        {
            var count = list.Count();

            list.Context.Put(CountKey(list.BaseKey), count + 1);

            list.Replace(count, element);
        }
Example #3
0
        public static BigInteger Add <T>(this StorageList list, T element)
        {
            var index = list.Count();

            list.Context.Put(CountKey(list.BaseKey), index + 1);

            list.Replace(index, element);
            return(index);
        }