SHARE
TWEET

Untitled

tinyevil Jan 8th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. generic[K, C:Comparator[K]]
  2. struct Tree{
  3.     ...
  4. }
  5.  
  6. implementation Tree{
  7.  
  8.     generic[S]
  9.     method find(Self self, S key): bool
  10.     where Comparator[S].compare(K,S)
  11.     {
  12.         var node = self.root;
  13.         while (node != null) {
  14.             switch(self.c.compare(node.key, key)){
  15.             case GT: node = node.right;
  16.             case LT: node = node.left;
  17.             case EQ: return true;
  18.             }
  19.         }
  20.         return false;
  21.     }
  22.  
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top