Permalink
Browse files

Version bump

  • Loading branch information...
1 parent a2b718d commit 863a7c0ab004feba51836ddfd918734c0cd7dbe6 @samdunne committed Nov 28, 2012
Showing with 71 additions and 39 deletions.
  1. +6 −0 README.md
  2. +0 −7 lib/rdata/binary_tree.rb
  3. 0 lib/rdata/linked_lists.rb
  4. +23 −0 lib/rdata/queue.rb
  5. +41 −31 lib/rdata/stack.rb
  6. +1 −1 lib/rdata/version.rb
View
6 README.md
@@ -7,6 +7,12 @@
gem install rdata
```
+Or in a Gemfile
+
+```ruby
+gem 'rdata'
+```
+
## Usage
```ruby
require 'rdata'
View
7 lib/rdata/binary_tree.rb
@@ -1,7 +0,0 @@
-module RData
-
- class BinaryTree
-
- end
-
-end
View
0 lib/rdata/linked_lists.rb
No changes.
View
23 lib/rdata/queue.rb
@@ -0,0 +1,23 @@
+module RData
+
+ class Queue
+
+ def initialize
+ @queue = Array[]
+ @head, @tail = 0
+ end
+
+ def enqueue(x)
+ @queue[@tail] = x
+ @tail = (@tail == @length) ? 1 : @tail - 1
+ end
+
+ def dequeue
+ x = @head
+ @head = (@head == @length) ? 1 : @head + 1
+ return x
+ end
+
+ end
+
+end
View
72 lib/rdata/stack.rb
@@ -1,34 +1,44 @@
+=begin
+
+This is the Stack class. It allows easy implementation of stacks and use of their operations
+
+# @stack = RData.Stack
+# @stack.operation
+# ... etc ...
+
+=end
+
module RData
-
- class Stack
-
- def initialize
- @selfStack = Array[]
- @top = 0
- end
-
- def top
- return @selfStack[@top]
- end
-
- def push(x)
- @top = @top + 1
- @selfStack[@top] = x
- end
-
- def pop
- if self.is_empty? == "true"
- raise '[underflow] Cannot pop data from an empty stack'
- else
- @top = @top - 1
- return @selfStack[@top + 1]
- end
- end
-
- def is_empty?
- (@top == 0) ? 'true' : 'false'
- end
-
- end
+
+ class Stack
+
+ def initialize
+ @stack = Array[]
+ @top = 0
+ end
+
+ def top
+ return @stack[@top]
+ end
+
+ def push(x)
+ @top = @top + 1
+ @stack[@top] = x
+ end
+
+ def pop
+ if self.is_empty? == "true"
+ raise '[underflow] Cannot pop data from an empty stack'
+ else
+ @top = @top - 1
+ return @stack[@top + 1]
+ end
+ end
+
+ def is_empty?
+ (@top == 0) ? 'true' : 'false'
+ end
+
+ end
end
View
2 lib/rdata/version.rb
@@ -1,3 +1,3 @@
module RData
- VERSION = "0.0.1"
+ VERSION = "0.2.0"
end

0 comments on commit 863a7c0

Please sign in to comment.