コード例 #1
0
        private Node AllocateNode(out int nodeId)
        {
            // Expand the node pool as needed
            if (this.freeList == NULL_NODE)
            {
                VoltDebug.Assert(this.nodeCount == this.nodeCapacity);

                // The free list is empty -- rebuild a bigger pool
                Node[] oldNodes = this.nodes;
                this.nodeCapacity = VoltUtil.ExpandArray(ref this.nodes);
                Array.Copy(oldNodes, this.nodes, this.nodeCount);

                // Build a linked list for the free list
                // The parent pointer becomes the "next" pointer
                for (int i = this.nodeCount; i < this.nodeCapacity - 1; ++i)
                {
                    this.nodes[i] = new Node(i + 1, -1);
                }

                this.nodes[this.nodeCapacity - 1] = new Node(NULL_NODE, -1);
                this.freeList = this.nodeCount;
            }

            // Peel a node off the free list.
            nodeId = this.freeList;
            Node result = this.nodes[nodeId];

            this.freeList = result.parentOrNext;
            result.Reset();

            this.nodeCount++;
            return(result);
        }
コード例 #2
0
ファイル: VoltBuffer.cs プロジェクト: chismar/MyNetworkEngine
        internal void Add(T[] bodies, int count)
        {
            if ((this.count + count) >= this.items.Length)
            {
                VoltUtil.ExpandArray(ref this.items, (this.count + count));
            }

            Array.Copy(bodies, 0, this.items, this.count, count);
            this.count += count;
        }
コード例 #3
0
ファイル: VoltBuffer.cs プロジェクト: chismar/MyNetworkEngine
        /// <summary>
        /// Adds a new element to the end of the list. Returns the index of the
        /// newly-indexed object.
        /// </summary>
        internal void Add(T body)
        {
            if (this.count >= this.items.Length)
            {
                VoltUtil.ExpandArray(ref this.items);
            }

            this.items[this.count] = body;
            this.count++;
        }
コード例 #4
0
        public void AddBody(VoltBody body)
        {
            if (this.count >= this.bodies.Length)
            {
                VoltUtil.ExpandArray(ref this.bodies);
            }

            this.bodies[this.count] = body;
            body.ProxyId            = this.count;
            this.count++;
        }
コード例 #5
0
        /// <summary>
        /// Adds a new element to the end of the list. Returns the index of the
        /// newly-indexed object.
        /// </summary>
        public void Add(T value)
        {
            if (this.count >= this.values.Length)
            {
                VoltUtil.ExpandArray(ref this.values);
            }

            this.values[this.count] = value;
            value.Index             = this.count;
            this.count++;
        }