Top Level Namespace

Defined Under Namespace

Modules: Rubydatastructures Classes: RubyDataStructures

Instance Method Summary collapse

Instance Method Details

#aqueue(size) ⇒ Object



28
29
30
# File 'lib/RubyDataStructures/macros.rb', line 28

def aqueue size
  RubyDataStructures::QueueAsArray.new size
end

#fifo_stack(size = 1) ⇒ Object



1
2
3
# File 'lib/RubyDataStructures/macros.rb', line 1

def fifo_stack size=1
  RubyDataStructures::FifoStack.new size
end

#linked_list(type = :single) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/RubyDataStructures/macros.rb', line 17

def linked_list(type = :single)
  case type
  when :single 
    RubyDataStructures::SinglyLinkedList.new 
  when :double, :dbl
    RubyDataStructures::DoublyLinkedList.new
  else
    raise ArgumentError, "Unknown or unsupported kind of Linked List: #{type}, must be: :single or :double"
  end
end

#max_heap(*array) ⇒ Object



13
14
15
# File 'lib/RubyDataStructures/macros.rb', line 13

def max_heap(*array)
  RubyDataStructures::MaxHeap.build(array.flatten)
end

#multi_array(*dimensions) ⇒ Object



9
10
11
# File 'lib/RubyDataStructures/macros.rb', line 9

def multi_array(*dimensions)
  RubyDataStructures::MultiDimensionalArray.new(*dimensions)
end

#stack(size = 1) ⇒ Object



5
6
7
# File 'lib/RubyDataStructures/macros.rb', line 5

def stack size=1
  RubyDataStructures::Stack.new size
end