Class: List
- Inherits:
-
Object
- Object
- List
- Defined in:
- lib/lib/list.rb
Instance Attribute Summary collapse
-
#h ⇒ Object
protected - in ruby this doesn’t play well with static/inline methods.
-
#length ⇒ Object
Returns the value of attribute length.
-
#q ⇒ Object
Returns the value of attribute q.
Instance Method Summary collapse
- #add(item) ⇒ Object
-
#initialize ⇒ List
constructor
A new instance of List.
- #iterator ⇒ Object
Constructor Details
#initialize ⇒ List
Returns a new instance of List.
6 7 8 |
# File 'lib/lib/list.rb', line 6 def initialize @length = 0 end |
Instance Attribute Details
#h ⇒ Object
protected - in ruby this doesn’t play well with static/inline methods
12 13 14 |
# File 'lib/lib/list.rb', line 12 def h @h end |
#length ⇒ Object
Returns the value of attribute length.
17 18 19 |
# File 'lib/lib/list.rb', line 17 def length @length end |
#q ⇒ Object
Returns the value of attribute q.
13 14 15 |
# File 'lib/lib/list.rb', line 13 def q @q end |
Instance Method Details
#add(item) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lib/list.rb', line 19 def add(item) x = [item] if @h == nil @h = x else @q[1] = x end @q = x @length+=1 end |
#iterator ⇒ Object
30 31 32 |
# File 'lib/lib/list.rb', line 30 def iterator ::X_List::ListIterator.new(@h) end |