Class: Rake::LinkedList
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
Enumerable
|
|
Inherits: | Object |
Defined in: | lib/rake/linked_list.rb |
Overview
Polylithic linked list structure used to implement several data structures in ::Rake.
Constant Summary
Class Method Summary
-
.cons(head, tail)
Cons a new head onto the tail list.
-
.empty
The standard empty list class for the given
LinkedList
class. -
.make(*args)
Make a list out of the given arguments.
- .new(head, tail = EMPTY) ⇒ LinkedList constructor
Instance Attribute Summary
-
#empty? ⇒ Boolean
readonly
Is the list empty?
- #head readonly
- #tail readonly
Instance Method Summary
-
#==(other)
Lists are structurally equivalent.
-
#conj(item)
Polymorphically add a new element to the head of a list.
-
#each
For each item in the list.
-
#inspect
Same as #to_s, but with inspected items.
-
#to_s
Convert to string: LL(item, item…).
Constructor Details
.new(head, tail = EMPTY) ⇒ LinkedList
Class Method Details
.cons(head, tail)
Cons a new head onto the tail list.
.empty
The standard empty list class for the given LinkedList
class.
# File 'lib/rake/linked_list.rb', line 75
def self.empty self::EMPTY end
.make(*args)
Make a list out of the given arguments. This method is polymorphic
Instance Attribute Details
#empty? ⇒ Boolean
(readonly)
Is the list empty?
# File 'lib/rake/linked_list.rb', line 22
def empty? false end
#head (readonly)
[ GitHub ]# File 'lib/rake/linked_list.rb', line 8
attr_reader :head, :tail
#tail (readonly)
[ GitHub ]# File 'lib/rake/linked_list.rb', line 8
attr_reader :head, :tail
Instance Method Details
#==(other)
Lists are structurally equivalent.
#conj(item)
Polymorphically add a new element to the head of a list. The type of head node will be the same list type as the tail.
# File 'lib/rake/linked_list.rb', line 17
def conj(item) self.class.cons(item, self) end
#each
For each item in the list.
#inspect
Same as #to_s, but with inspected items.
# File 'lib/rake/linked_list.rb', line 44
def inspect items = map { |item| item.inspect }.join(", ") "LL(#{items})" end
#to_s
Convert to string: LL(item, item…)
# File 'lib/rake/linked_list.rb', line 38
def to_s items = map { |item| item.to_s }.join(", ") "LL(#{items})" end