Libraries
Search…
Implementation
Class: DataStructure.

Constants

TYPES private

A frozen Array containing class constants.

Attributes

Methods

DataStructure.types()

1
def DataStructure.types()
2
return TYPES
3
end
Copied!
Gets the DataStructure types. Returns the Array reference.

DataStructure.instance?(obj = nil)

1
def DataStructure.instance?(obj = nil)
2
3
boolean = false
4
TYPES.each { |type|
5
6
if (obj.is_a?(type))
7
boolean = true
8
end
9
10
}
11
return boolean
12
13
end
Copied!
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)

1
def DataStructure.type?(type = nil)
2
3
element = self.types_element?(type)
4
element_child = self.type_child?(type)
5
boolean = (element || element_child)
6
return boolean
7
8
end
Copied!
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)

1
def DataStructure.types_element?(type = nil)
2
boolean = TYPES.include?(type)
3
return boolean
4
end
Copied!
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)

1
def DataStructure.type_child?(type = nil)
2
3
boolean = false
4
type_ancestors = type.ancestors()
5
type_ancestors.each { |ancestor|
6
7
if (types_element?(ancestor) && !types_element?(type))
8
boolean = true
9
end
10
11
}
12
return boolean
13
14
end
Copied!
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.
Last modified 1yr ago