JMatchJava模式匹配库
示例代码:
static RBNode balance(int color, int value, RBTree left, RBTree right) { if (color == BLACK) { switch (value,left,right) { case int z, RBNode(RED,int y,RBNode(RED,int x,RBTree a,RBTree b),RBTree c), RBTree d: case z, RBNode(RED,x,a,RBNode(RED,y,b,c)),d: case x, a, RBNode(RED,z,RBNode(RED,y,b,c),d): case x, a, RBNode(RED,y,b,RBNode(RED,z,c,d)): return RBNode(RED,y,RBNode(BLACK,x,a,b),RBNode(BLACK,z,c,d)); } } return RBNode(color, value, left, right); }
评论