rbtree-jruby 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Binary file
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: rbtree-jruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Isaiah Peng
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-10 00:00:00.000000000 Z
12
+ date: 2012-12-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -113,16 +113,14 @@ files:
113
113
  - README.md
114
114
  - Rakefile
115
115
  - VERSION
116
- - java/src/rbtree/ext/Color.java
116
+ - benchmark/bm.rb
117
+ - benchmark/bm1.rb
118
+ - benchmark/result.png
119
+ - benchmark/result.txt
117
120
  - java/src/rbtree/ext/MultiRBTree.java
118
121
  - java/src/rbtree/ext/MultiRBTreeService.java
119
- - java/src/rbtree/ext/NilNode.java
120
- - java/src/rbtree/ext/Node.java
121
122
  - lib/rbtree.rb
122
123
  - lib/rbtree/ext/multi_r_b_tree.jar
123
- - lib/rbtree/ext/multi_red_black_tree.jar
124
- - lib/rbtree/ext/rbtree.jar
125
- - lib/rbtree/ext/red_black_tree.jar
126
124
  - rbtree-jruby.gemspec
127
125
  - test/helper.rb
128
126
  - test/test_rbtree.rb
@@ -1,6 +0,0 @@
1
- package rbtree.ext;
2
-
3
- public enum Color {
4
- RED, BLACK;
5
- }
6
-
@@ -1,24 +0,0 @@
1
- package rbtree.ext;
2
-
3
- import org.jruby.RubyInteger;
4
-
5
- public class NilNode extends Node {
6
- private static NilNode nil = null;
7
- private NilNode() {
8
- this.color = Color.BLACK;
9
- this.left = this.right = this.parent = null;
10
- }
11
-
12
- public static NilNode getInstance() {
13
- if (nil == null) {
14
- nil = new NilNode();
15
- }
16
- return nil;
17
- }
18
-
19
- @Override
20
- public boolean isNull() {
21
- return true;
22
- }
23
- }
24
-
@@ -1,98 +0,0 @@
1
- package rbtree.ext;
2
-
3
- import org.jruby.RubyObject;
4
- import org.jruby.runtime.builtin.IRubyObject;
5
-
6
- public class Node {
7
- protected Color color;
8
- protected RubyObject key;
9
- protected IRubyObject value;
10
- protected Node left;
11
- protected Node right;
12
- protected Node parent;
13
-
14
- protected Node() {}
15
-
16
- protected Node(IRubyObject key, IRubyObject value) {
17
- this(key, value, Color.RED);
18
- }
19
-
20
- protected Node(IRubyObject key, IRubyObject value, Color color) {
21
- this.key = (RubyObject) key;
22
- this.value = value;
23
- this.color = color;
24
- this.left = this.right = this.parent = NilNode.getInstance();
25
- }
26
-
27
- public boolean isRed() {
28
- return this.color == Color.RED;
29
- }
30
-
31
- public boolean isBlack() {
32
- return !isRed();
33
- }
34
-
35
- public RubyObject getKey() {
36
- return this.key;
37
- }
38
-
39
- public IRubyObject getValue() {
40
- return this.value;
41
- }
42
-
43
- public Node getLeft() {
44
- return this.left;
45
- }
46
-
47
- public Node getRight() {
48
- return this.right;
49
- }
50
- public Node getParent() {
51
- return this.parent;
52
- }
53
- public Node getGrandParent() {
54
- return this.parent.getParent();
55
- }
56
- public Color getColor() {
57
- return this.color;
58
- }
59
- public void setLeft(Node node) {
60
- this.left = node;
61
- }
62
- public void setRight(Node node) {
63
- this.right = node;
64
- }
65
- public void setParent(Node node) {
66
- this.parent = node;
67
- }
68
- public void setColor(Color color) {
69
- this.color = color;
70
- }
71
- public void setKey(IRubyObject key) {
72
- this.key = (RubyObject) key;
73
- }
74
- public void setValue(IRubyObject val) {
75
- this.value = val;
76
- }
77
- public void setBlack() {
78
- this.color = Color.BLACK;
79
- }
80
- public void setRed() {
81
- this.color = Color.RED;
82
- }
83
- public boolean isNull() {
84
- return false;
85
- }
86
-
87
- public boolean isLeft() {
88
- return this == this.parent.left;
89
- }
90
-
91
- public boolean isRight() {
92
- return this == this.parent.right;
93
- }
94
-
95
- public Node getSibling() {
96
- return isLeft() ? this.parent.right : this.parent.left;
97
- }
98
- }
Binary file
Binary file