示例#1
0
文件: cpBBTree.cs 项目: kfazi/AgarIo
        public void PairRecycle(Pair pair)
        {
            //TODO: CHECK IF WORKS
            // Share the pool of the master tree.
            // TODO: would be lovely to move the pairs stuff into an external data structure.
            var tree = GetMasterTree();

            pair.a.prev = tree.pooledPairs;
            tree.pooledPairs = pair;
        }
示例#2
0
文件: cpBBTree.cs 项目: kfazi/AgarIo
        public Pair MakePair(Node leafA, Pair nextA, Node leafB, Pair nextB)
        {
            var pair = this.pooledPairs;
            if (pair != null)
            {
                this.pooledPairs = pair.a.prev;

                pair.a.prev = null;
                pair.a.leaf = leafA;
                pair.a.next = nextA;

                pair.b.prev = null;
                pair.b.leaf = leafB;
                pair.b.next = nextB;

                return pair;
            }
            else
            {
                cp.numPairs++;
                return new Pair(leafA, nextA, leafB, nextB);
            }
        }
示例#3
0
文件: cpBBTree.cs 项目: kfazi/AgarIo
 public Thread(Pair prev, Node leaf, Pair next)
 {
     this.prev = prev;
     this.leaf = leaf;
     this.next = next;
 }
示例#4
0
文件: cpBBTree.cs 项目: kfazi/AgarIo
        public static void Unlink(Pair prev, Node leaf, Pair next)
        {
            if (next != null)
            {
                if (next.a.leaf == leaf)
                    next.a.prev = prev;
                else next.b.prev = prev;
            }

            if (prev != null)
            {
                if (prev.a.leaf == leaf) prev.a.next = next;
                else prev.b.next = next;
            }
            else
            {
                leaf.pairs = next;
            }
        }
示例#5
0
文件: cpBBTree.cs 项目: kfazi/AgarIo
 // Objects created with constructors are faster than object literals. :(
 public Pair(Node leafA, Pair nextA, Node leafB, Pair nextB)
 {
     a = new Thread(null, leafA, nextA);
     b = new Thread(null, leafB, nextB);
     id = 0;
 }