for (rowsize = 2; rowsize + rowsize < count; rowsize <<= 1)
for (rowsize = 2; rowsize + rowsize <= count; rowsize <<= 1)
  private void fabricateTree(final int count)  {    if (count == 0)      return;    // We color every row of nodes black, except for the overflow nodes.    // I believe that this is the optimal arrangement. We construct the tree    // in place by temporarily linking each node to the next node in the row,    // then updating those links to the children when working on the next row.    // Make the root node.    root = new Node(null, null, BLACK);    size = count;    Node row = root;    int rowsize;    // Fill each row that is completely full of nodes.    for (rowsize = 2; rowsize + rowsize < count; rowsize <<= 1)      {        Node parent = row;        Node last = null;        for (int i = 0; i < rowsize; i += 2)          {            Node left = new Node(null, null, BLACK);            Node right = new Node(null, null, BLACK);            left.parent = parent;            left.right = right;            right.parent = parent;            parent.left = left;            Node next = parent.right;            parent.right = right;            parent = next;            if (last != null)              last.right = left;            last = right;          }        row = row.left;      }    // Now do the partial final row in red.    int overflow = count - rowsize;    Node parent = row;    int i;    for (i = 0; i < overflow; i += 2)      {        Node left = new Node(null, null, RED);        Node right = new Node(null, null, RED);        left.parent = parent;        right.parent = parent;        parent.left = left;        Node next = parent.right;        parent.right = right;        parent = next;      }    // Add a lone left node if necessary.    if (i - overflow == 0)      {        Node left = new Node(null, null, RED);        left.parent = parent;        parent.left = left;        parent = parent.right;        left.parent.right = nil;      }    // Unlink the remaining nodes of the previous row.    while (parent != nil)      {        Node next = parent.right;        parent.right = nil;        parent = next;      }  }