Gran Torino
Announcement
Collapse
No announcement yet.
Hit control V now.
Collapse
X
-
I wasn't born with enough middle fingers.
[Brandon Roderick? You mean Brock's Toadie?][Hanged from Yggdrasil]
Comment
-
Three chapters from the middle of Galnemer's next novel, which I am now proofreading prior to submission to her editor.
No way you guys are reading that for free. :wiglaf:"My nation is the world, and my religion is to do good." --Thomas Paine
"The subject of onanism is inexhaustable." --Sigmund Freud
Comment
-
public class LLRB, Value>
{
private static final boolean RED = true;
private static final boolean BLACK = false;
private Node root;
private class Node
{
private Key key;
private Value val;
private Node left, right;
private boolean color;
Node(Key key, Value val)
{
this.key = key;
this.val = val;
this.color = RED;
}
}
public Value search(Key key)
{
Node x = root;
while (x != null)
{
int cmp = key.compareTo(x.key);
if (cmp == 0) return x.val;
else if (cmp < 0) x = x.left;
else if (cmp > 0) x = x.right;
}
return null;
}
public void insert(Key key, Value value)
{
root = insert(root, key, value);
root.color = BLACK;
}
private Node insert(Node h, Key key, Value value)
{
if (h == null) return new Node(key, value);
if (isRed(h.left) && isRed(h.right)) colorFlip(h);
int cmp = key.compareTo(h.key);
if (cmp == 0) h.val = value;
else if (cmp < 0) h.left = insert(h.left, key, value);
else
h.right = insert(h.right, key, value);
if (isRed(h.right) && !isRed(h.left)) h = rotateLeft(h);
if (isRed(h.left) && isRed(h.left.left)) h = rotateRight(h);
return h;
}
}<p style="font-size:1024px">HTML is disabled in signatures </p>
Comment
Comment