A 0
Integer
literal.
A 1
Integer
literal.
The list's element quantity, type Integer
.
The list's base NodeAdapter
. base
is either nil
or a NodeAdapter
instance.
def initialize(d_or_n = nil)arg_class = d_or_n.class()casewhen arg_class.equal?(Node)n_a = NodeAdapter.new(d_or_n)self.base = n_aincrement_s()when arg_class.equal?(NodeAdapter)self.base = d_or_nincrement_s()when DataType.type?(arg_class)self.base = initialize_node(d_or_n)increment_s()elseraise(ArgumentError,"#{d_or_n} is neither a DataType or Node family type instance.")endend
Initializes a LinkedList
instance. Takes a DataType type, Node
, or NodeAdapter
instance. Sets the instance's base
the argument NodeAdapter
, or, instantiates a NodeAdapter
using the argument data or Node
instance, and sets base
the instantiation. Returns the LinkedList
.
def shallow_clone()n_a = NodeAdapter.new(base())n_a.size = size()if (frozen?())n_a.freeze()endreturn n_aend
Shallowly clones self
. Attribute references are the same. Returns the LinkedList
clone.
def clone_df()clone = shallow_clone()c_iter = LinkedListIterator.new(clone.base())iter = LinkedListIterator.new(base())list_element = iter.element()​if (list_element.equal?(base()))​while (!list_element.pioneer())​cdf_node = list_element.clone_df()clone.insert(list_element, cdf_node)c_iter.next()​endcdf_node = list_element.clone_df()clone.insert(cdf_node, c_iter.element())​endif (frozen?())clone.freeze()endreturn cloneend
Deeply clones. Returns the LinkedList
clone. No NodeAdapter
references are identical. The data
references are identical.
def size()return @sizeend