Implementation

Class: DataStructure.

Constants

TYPES private

A frozen Array containing class constants.

Attributes

Methods

DataStructure.types()

def DataStructure.types()
return TYPES
end

Gets the DataStructure types. Returns the Array reference.

DataStructure.instance?(obj = nil)

def DataStructure.instance?(obj = nil)
boolean = false
TYPES.each { |type|
if (obj.is_a?(type))
boolean = true
end
}
return boolean
end

Predicate. Verifies an object is an Array, Hash, Queue, SizedQueue, Node, or LinkedList instance. Takes an argument object. Returns true in the case the object's class or an ancestor class is Array, Hash, Queue, SizedQueue, Node, or LinkedList. Returns false otherwise.

DataStructure.type?(type = nil)

def DataStructure.type?(type = nil)
element = self.types_element?(type)
element_child = self.type_child?(type)
boolean = (element || element_child)
return boolean
end

Predicate. Verifies a type is a DataStructure type. Takes an argument type identifier. Returns true in the case the argument is Array, Hash, Queue, SizedQueue, Node, or LinkedList, or, an ancestor is in the type set. Returns false otherwise.

DataStructure.types_element?(type = nil)

def DataStructure.types_element?(type = nil)
boolean = TYPES.include?(type)
return boolean
end

Predicate. Verifies an identifier is a TYPES element. Takes any identifier argument. Returns true in the case the argument is a TYPES element. false otherwise.

DataStructure.type_child?(type = nil)

def DataStructure.type_child?(type = nil)
boolean = false
type_ancestors = type.ancestors()
type_ancestors.each { |ancestor|
if (types_element?(ancestor) && !types_element?(type))
boolean = true
end
}
return boolean
end

Predicate. Verifies a type is a TYPES child. Takes any identifier argument. Returns true in the case a TYPES element is the argument's ancestor. false otherwise.