FMUTIL  0.1
Fortran Miscellaneous UTILities
vector.f90 File Reference

Go to the source code of this file.

Data Types

type  vectors::vecelem
 Abstract vector element type that must be extended by user to define the type for the Vector elements. More...
 
interface  vectors::assign_vecelem
 Interface for the procedure invoked during assignment of VecElem. More...
 
type  vectors::invalidvecelem
 Invalid Vector element type that is returned in case of an exception. More...
 
type  vectors::bkt
 Internal Bucket sturcture. Each bucket can contain a number of elements. More...
 
type  vectors::bktptr
 Pointer to a single bucket. More...
 
type  vectors::vector
 Vector type. More...
 

Modules

module  vectors
 Vector module.
 

Functions/Subroutines

subroutine vectors::initialize (me, NewBktsToAllocate, BktCap, MoldElem)
 Optional procedure to initialize Vector type and allocate internal storage. It can be used to modify the default settings for storage allocation. If Init is not called first, Vector is initialized using the default settings and storage is allocated on the first call to push data in the Vector. This procedure will only change the number of new buckets to create on Vector capacity increase if it is invoked after the first call to push data in the Vector. More...
 
pure integer function vectors::vec_size (me)
 Returns the total number of allocated elements in the Vector. More...
 
pure integer function vectors::capacity (me)
 Returns the total number of elements that can be saved in the Vector without any need for increasing the memory footprint. More...
 
pure integer function vectors::nusedbkts (me)
 Returns the total number of internal data buckets allocated by the Vector. Each bucket can contain multiple elements defined by its capacity. More...
 
subroutine vectors::reserve (me, n)
 Increases the capcity of Vector to 'n' if the current capacity is smaller than 'n'. More...
 
subroutine vectors::shrinktofit (me)
 Deallocate unused buckets to make Capacity as close to Size as possible. More...
 
class(vecelem) function, pointer vectors::elem_at (me, Index)
 Returns a pointer to the element with the requested index (1-based) Pointer will not be associated in case of an exception. More...
 
class(vecelem) function, allocatable vectors::elem_front (me)
 Returns the element with the index=1. More...
 
class(vecelem) function, allocatable vectors::elem_back (me)
 Returns the last element in the Vector. More...
 
class(vecelem) function, dimension(:), allocatable vectors::vec_slice (me, lower, upper, stride)
 Returns the element array within the requested lower and upper bounds. This is inefficient as it copies the requested slice of the Vector in an array and returns it. If bounds result in zero-length slice, an empty array of VecElem type is returned. More...
 
class(vecelem) function, dimension(:), pointer vectors::bkt_slice (me, lower, upper)
 Returns a pointer to the Vector slice specified using the user-specified lower and upper bounds. If the requested slice is beyond the extent of the data bucket that contains the element corresponding to the lower bound, then the data array is truncated at the bucket boundary and the upper bound is updated to indicate the actual upper bound of data that can be referenced using the returned pointer. This is an efficient method as no copying of data is done. In case of an exception, the returned pointer will not be associated. More...
 
integer function vectors::push_back (me, velem)
 Function to add an element at the back of the vector. More...
 
class(vecelem) function, allocatable vectors::pop_back (me)
 Function to extract the last element of the vector. More...
 
subroutine vectors::elem_insert (me, pos, NewElems, count)
 Inserts the element/elements at the given index and relocate existing elements at the later indices. Very inefficient way to add elements to Vector unless elements are inserted after the last element. More...
 
subroutine vectors::elem_erase (me, lower, upper)
 Delete the element/elements between and including lower and upper bounds. The elements are moved to fill up empty locations. Very inefficient way to delete elements from Vector. More...
 
subroutine vectors::clear (me)
 Clear the contents of Vector but the bucket memory is not deallocated. More...
 
subroutine vectors::create_newbkts (me, NumBkts)
 Subroutine to allocate storage for a new bucket. More...
 
pure subroutine vectors::index2bkt (me, Index, Bkt, BktOffset)
 Converts Vector index to bucket number and offset into the bucket. More...
 
subroutine vectors::assign_invalidelem (lhs, rhs)
 
subroutine vectors::assignvector (lhs, rhs)
 Subroutine for Vector assignment operator. More...
 
subroutine vectors::destroy (me)
 Destructor. More...
 
subroutine vectors::bktinit (me, status, cap, mold_elem)
 Bucket Type Methods. More...
 
subroutine vectors::add_bktelem (me, offset, elem)
 
subroutine vectors::del_bktelem (me, offset)
 
subroutine vectors::bktclear (me)
 
class(vecelem) function, pointer vectors::bktelem (me, offset)
 
class(vecelem) function, dimension(:), pointer vectors::bktsliceptr (me, start_ind, end_ind)
 
pure logical function vectors::is_bktempty (me)
 
pure integer function vectors::bktsz (me)
 

Variables

integer, parameter vectors::default_bktcap = 3
 Default capacity of internal buckets. More...
 
integer, parameter vectors::default_newbktsallocated = 2
 Default number of buckets to create on vector capacity increase. More...