|
|
vector.h File ReferenceDefinition of the Tvector type and the associated functions. More... #include "boolean.h" #include <stdio.h> Go to the source code of this file.
Detailed DescriptionDefinition of the Tvector type and the associated functions implementing a generic vector structure. The vectors are like arrays of any possible type. To define a vector on a particular type, we need of two basic operators defined on this type:
Optionally, to perform search operations we will need a comparison operator. In this same file (vector.h) we give copy constructors, destructor and comparison operators for the basic and most common types used to define vectors: identifiers (i.e., unsigned int), doubles, and pointers. Note that when removing an element from a vector the vector is not compacted and, thus, the vector can have empty entries. Therefore, before using the elements obtained from a vector, we have to check whether they are valid or not (a NULl pointer is returned when accessing an empty vector position). Many sets (constants, variables, equations,....) could be implemented using Tvector. Currently this is not so for legacy reason (those objects where implemented much before Tvector, for previous versions of cuik). A similar issue occurs with Tlist : it could be implemented using the philosophy of Tvector (with a copy constructor, a destructor,... stored in the generic data, Tlist in this case). This is not this way becaus Tlist was implemented much before Tvector. Definition in file vector.h. Function Documentation
Copy constructor for identifiers. To be used when defining a vector of identifiers (i.e., unsigned int). This is a direct assignation.
Definition at line 24 of file vector.c. Referenced by InitHeap().
Here is the caller graph for this function:
Destructor for identifiers. To be used when defining a vector of identifiers (i.e., unsigned int). This basically frees the space taken by the identifier.
Definition at line 29 of file vector.c. Referenced by InitHeap().
Here is the caller graph for this function:
Copy constructor for doubles. To be used when defining a vector of pointers. This is a direct assignation.
Definition at line 54 of file vector.c. Referenced by CopyLink(), CreateBranch(), GenerateKinTree(), InitLink(), and InitMechanism().
Here is the caller graph for this function:
Destructor for void pointers. To be used when defining a vector of pointers. This basically frees the space taken by the pointer.
Definition at line 59 of file vector.c. Referenced by CopyLink(), CreateBranch(), GenerateKinTree(), InitLink(), and InitMechanism().
Here is the caller graph for this function:
Initializes an empty vector Examples of use:
Definition at line 67 of file vector.c. References Tvector::Copy, Tvector::Delete, Tvector::ele_size, Tvector::elements, Tvector::max_ele, NEW, and Tvector::num_ele. Referenced by CopyLink(), CreateBranch(), GenerateKinTree(), InitHeap(), InitLink(), and InitMechanism().
Here is the caller graph for this function:
Removes all the elements from a vector but it does not frees the allocated memory nor resets the maximum number of elements. If you plan to re-use a vector it is more efficient to reset it instead of deleting it and re-initializing it again.
Definition at line 83 of file vector.c. References Tvector::Delete, Tvector::elements, and Tvector::num_ele. Referenced by DeleteVector(), and ResetHeap().
Here is the caller graph for this function:
Initializes a vector from another vector.
Definition at line 101 of file vector.c. References Tvector::Copy, Tvector::Delete, Tvector::ele_size, Tvector::elements, Tvector::max_ele, NEW, and Tvector::num_ele. Referenced by CopyHeap().
Here is the caller graph for this function:
Returns the first (i.e., with lower identifier) free position in a vector.
Definition at line 125 of file vector.c. References Tvector::elements. Referenced by NewFreeVectorElement().
Here is the caller graph for this function:
Returns the number of elements in a vector. Note that the vector can have "holes", i.e., empty slots in position explicitly deleted using RemoveVectorElement.
Definition at line 136 of file vector.c. References Tvector::num_ele. Referenced by GetMechanismNJoints(), GetMechanismNLinks(), InitWorldKinCS(), LinkNBodies(), and nStepsBranch().
Here is the caller graph for this function:
Returns the maximum number of elements in a vector. Note that the vector can have "holes", i.e., empty slots in position explicitly deleted using RemoveVectorElement.
Definition at line 141 of file vector.c. References Tvector::max_ele. Checks if a vector is empty
Definition at line 146 of file vector.c. References Tvector::num_ele. Looks for an element in a vector.
Definition at line 151 of file vector.c. References FindPos().
Here is the call graph for this function:
Looks for an element in a vector.
Definition at line 156 of file vector.c. References Tvector::elements, FALSE, and TRUE. Referenced by ElementInVector().
Here is the caller graph for this function:
Adds an element at the end of the list.
Definition at line 179 of file vector.c. References Tvector::num_ele, and SetVectorElement(). Referenced by AddBody2Link(), AddStepToBranch(), and GenerateKinTree().
Here is the call graph for this function:
Here is the caller graph for this function:
Looks for a free vector position and stores the given element.
Definition at line 190 of file vector.c. References SetVectorElement(), and VectorFirstFreePos().
Here is the call graph for this function:
Adds an element to the vector in a given position. If the vector position was already occupied, the stored element is deleted before copying the new element.
Definition at line 201 of file vector.c. References Tvector::Copy, Tvector::Delete, Tvector::ele_size, Tvector::elements, Tvector::max_ele, MEM_EXPAND, NEW, and Tvector::num_ele. Referenced by AddElement2Heap(), AddJoint2Mechanism(), AddLink2Mechanism(), NewFreeVectorElement(), and NewVectorElement().
Here is the caller graph for this function:
Returns a pointer to a given vector element.
Definition at line 236 of file vector.c. References Tvector::elements. Referenced by DeleteBranch(), DistanceToSubBoxCenter(), ExtractMinElement(), GetBranchStep(), GetHeapElement(), GetHeapPosition(), GetLinkBody(), GetMechanismJoint(), GetMechanismLink(), HeapDown(), HeapUp(), InitWorldKinCS(), PointInSubBox(), and PointInSystemBox().
Here is the caller graph for this function:
Returns a pointer to a the last element of a vector.
Definition at line 244 of file vector.c. References Tvector::elements, and Tvector::num_ele.
Removes an element from the vector. Note that elements in the vector are not compacted after the deletion. In this way indexes in other data structured refered to this vector still hold after the deletion. The drawnback is that we can end up with a vector with "holes" and we have to be carefull when retriving elements from the vector.
Definition at line 252 of file vector.c. References Tvector::Delete, Tvector::elements, and Tvector::num_ele. Referenced by ExtractMinElement(), ExtractVectorElement(), and MoveVectorElement().
Here is the caller graph for this function:
Swaps two elements in a vector. This operation is provided since it is more efficient than extracting the two elements and then inserting them again in the vector in their new positions. If one of the two elements to swap is empty, this function triggers an error.
Definition at line 265 of file vector.c. References Tvector::elements, and Error(). Referenced by ExtractMinElement(), HeapDown(), and HeapUp().
Here is the call graph for this function:
Here is the caller graph for this function:
Extracts an element from a vector. The element is copied to the given buffer and removed from the vector. If the given element of the vector is empty, this function triggers an error.
Definition at line 285 of file vector.c. References Tvector::Copy, Tvector::elements, Error(), and RemoveVectorElement(). Referenced by ExtractMinElement().
Here is the call graph for this function:
Here is the caller graph for this function:
Moves a vector element from one position to another. If the element to move is empty, this function triggers an error. If the element where to store the moved element is full, it is removed before the moving.
Definition at line 306 of file vector.c. References Tvector::elements, Error(), and RemoveVectorElement().
Here is the call graph for this function:
Deletes the information stored in the vector and frees the allocated memory space.
Definition at line 332 of file vector.c. References ResetVector(). Referenced by DeleteBranch(), DeleteHeap(), DeleteLink(), DeleteMechanism(), and InitWorldKinCS().
Here is the call graph for this function:
Here is the caller graph for this function:
|