6 args.each { |obj| tuple.send :append, obj }
12 num.times { append nil }
15 # I'm not sure if these are 100% the right semantics. Please verify. -- flgr
16 def copy_from(other_tuple, start_idx = 0)
18 other_tuple.each do |value|
19 append(value) if idx >= start_idx
27 @current.value if @current
34 @current.value = value if @current
53 "#<Tuple:0x#{object_id.to_s(16)} #{fields} elements>"
59 str << ": #{join(", ", :inspect)}"
65 def join(sep, meth=:to_s)
66 join_upto(sep, fields, meth)
69 def join_upto(sep, count, meth=:to_s)
71 return str if count == 0 or empty?
72 count = fields if count >= fields
76 str << at(i).__send__(meth)
80 str << at(count).__send__(meth)
85 return self unless @head and @head.after
94 tuple = Tuple.new(num + @size)
95 @size.times { |i| tuple.put num + i, at(i) }
102 ary << ent unless ent.nil?
121 raise InvalidIndexError, "Index must be positive: attempted #{index} for #{self}" if index < 0
122 raise InvalidIndexError, "Index must be less than size: attempted #{index} for #{self}" if index >= size
131 forward while index > @index
132 backward while index < @index
136 return if @current == @tail
139 @current = @current.after
144 return if @current == @head
147 @current = @current.before
151 def insert(value, before, after)
152 node = Node.new(before, after, value)
153 @head = node if node.before.nil?
154 @tail = node if node.after.nil?
155 reset unless @current
162 node = Node.new(@tail, nil, value)
164 @head = node = Node.new(nil, nil, value)
166 reset unless @current
172 attr_accessor :before, :after, :value
174 def initialize(before, after, value=nil)
178 before.after = self if before
179 after.before = self if after