class Node
Node
. @class_description
A doubly-linked Node data structure library's implementation.
@attr back [Node]
A backward reference.
@attr data [DataType]
Any instance. Refer the Data Library {https://docs.diligentsoftware.org/data#classification Classification}.
@attr front [Node]
A forward reference.
Node
. @class_description
A doubly-linked Node data structure library's implementation.
@attr back [Node]
A backward reference.
@attr data [DataType]
Any instance. Refer the Data Library {https://docs.diligentsoftware.org/data#classification Classification}.
@attr front [Node]
A forward reference.
Constants
- VERSION
Public Class Methods
initialize(b_n = nil, dti = nil, f_n = nil). @description
Initializes Node instances.
@param b_n [Node]
The back reference assignment.
@param f_n [Node]
The front reference assignment.
@param dti [DataType]
A DataType type instance.
@return [Node]
An instance.
# File lib/node_impl.rb, line 37 def initialize(b_n = nil, dti = nil, f_n = nil) self.back = b_n self.data = dti self.front = f_n end
Public Instance Methods
(n = nil).¶ ↑
@description
Attribute equality operator. Compares the lhs and rhs's attributes.
@param n [.]
Any instance.
@return [TrueClass, FalseClass]
True in the case n is a Node and its attribute references are identical. False otherwise.
# File lib/node_impl.rb, line 137 def ==(n = nil) unless (n.instance_of?(Node)) return false else eq = (back().equal?(n.back_ref()) && (data().equal?(n.data())) && (front().equal?(n.front_ref()))) return eq end end
b(). @description
Gets back.
@return [Node, NilClass]
back's reference, frozen.
# File lib/node_impl.rb, line 87 def b() return back().freeze() end
clone_df
(). @description
Deeply clones.
@return [Node]
A deep clone. No Node references are identical. Data references are identical.
# File lib/node_impl.rb, line 68 def clone_df() b = back().clone() d = data() f = front().clone() n = Node.new(b, d, f) if (frozen?()) return n.freeze() else return n end end
data(). @description
Gets 'data'.
@return [DataType]
data's reference, frozen.
# File lib/node_impl.rb, line 96 def data() return @data end
data=(dti = nil). @description
Sets 'data'.
@param dti [DataType]
The data setting.
@return [DataType]
The argument.
@raise [DataError]
In the case the argument is any type other than a DataType type.
# File lib/node_impl.rb, line 118 def data=(dti = nil) error = DataError.new() unless (DataType.instance?(dti)) raise(error, error.message()) else @data = dti end end
f(). @description
Gets front.
@return [Node, NilClass]
front's reference, frozen.
# File lib/node_impl.rb, line 105 def f() return front().freeze() end
inspect(). @description
Gets an existing Diagram, or builds one.
@return [String]
self's diagram.
# File lib/node_impl.rb, line 165 def inspect() df_singleton = DiagramFactory.instance() diagram = df_singleton.diagram(self) return diagram.form() end
shallow_clone
(). @description
Shallowly clones.
@return [Node]
A clone. The clone and self are not identical, and share the same attribute references.
# File lib/node_impl.rb, line 51 def shallow_clone() n = Node.new(back(), data(), front()) if (frozen?()) return n.freeze() else return n end end
Protected Instance Methods
back_ref
(). @description
Gets back's reference.
@return [Node, NilClass]
The reference.
# File lib/node_impl.rb, line 180 def back_ref() return back() end
front_ref
(). @description
Gets front's reference.
@return [Node, NilClass]
front's reference.
# File lib/node_impl.rb, line 189 def front_ref() return front() end
Private Instance Methods
back(). @description
Gets back.
@return [Node]
back's Node reference.
# File lib/node_impl.rb, line 200 def back() return @back end
back=(n = nil). @description
Assigns back the node.
@param n [Node]
A Node or NilClass instance becoming the back instance.
@raise [NodeError]
In the case the argument is anything other than a Node instance.
# File lib/node_impl.rb, line 220 def back=(n = nil) error = NodeError.new() if (!(n.instance_of?(Node) || n.nil?())) raise(error, error.message()) else @back = n end end
front(). @description
Gets front.
@return [Node]
front's Node reference.
# File lib/node_impl.rb, line 209 def front() return @front end
front=(n = nil). @description
Assigns front the node.
@param n [Node]
A Node or NilClass instance becoming the front Node reference.
# File lib/node_impl.rb, line 236 def front=(n = nil) error = NodeError.new() if (!(n.instance_of?(Node) || n.nil?())) raise(error, error.message()) else @front = n end end