Esempio n. 1
0
        public static FixedSizeList <T> Create(Pointer pointer, IList <T> items)
        {
            var accessor = TypeAccessor <T> .Instance;

            if (accessor.IsStruct)
            {
                throw new InvalidOperationException("Lists of structs cannot be created retrospectively, since the list *is* the data");
            }

            if (items == null)
            {
                return(default(FixedSizeList <T>));
            }
            if (items.Count == 0)
            {
                return(FixedSizeList <T> .Create(pointer, 0));
            }

            FixedSizeList <T> list = accessor.CreateList(pointer, items.Count);

            for (int i = 0; i < items.Count; i++)
            {
                list[i] = items[i];
            }
            return(list);
        }
Esempio n. 2
0
        public static FixedSizeList <T> Create(Pointer pointer, IList <T> items)
        {
            if (items == null)
            {
                return(default(FixedSizeList <T>));
            }
            if (items.Count == 0)
            {
                return(FixedSizeList <T> .Create(pointer, 0));
            }

            var accessor           = StructAccessor <T> .Instance;
            FixedSizeList <T> list = accessor.IsPointer
                ? accessor.CreateList(pointer, items.Count, ElementSize.EightBytesPointer)
                : accessor.CreateList(pointer, items.Count);

            for (int i = 0; i < items.Count; i++)
            {
                list[i] = items[i];
            }
            return(list);
        }
Esempio n. 3
0
 public FixedSizeList <T> AllocateList <T>(IList <T> items)
 {
     return(FixedSizeList <T> .Create(this.Root, items));
 }