Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
vector< T, MINSIZE > Struct Template Reference

Vector template. More...

#include <cube_vector.hpp>

Public Member Functions

 vector ()
 Default constructor. More...
 
 vector (const vector &v)
 Copy constructor. More...
 
 ~vector ()
 Destructor. More...
 
vector< T > & operator= (const vector< T > &v)
 Operator =. More...
 
T & add (const T &x)
 Add new index to vector. More...
 
T & add ()
 Add new EMPTY index to vector. More...
 
T & dup ()
 Duplicate vector's last index. More...
 
void move (vector< T > &v)
 copy vector from vector reference More...
 
bool inrange (size_t i) const
 safety check: tests if index i exists in this vector More...
 
bool inrange (int i) const
 safety check: tests if index i exists in this vector integer version: i must be greater (or equal to) 0 More...
 
T & pop ()
 get the last index and decrement the vector's size More...
 
T & last ()
 get the last index More...
 
void drop ()
 decrement vector's size and call the DESTRUCTOR of the template in the last index More...
 
bool empty () const
 is this vector empty? More...
 
int capacity () const
 return size of reserved memory More...
 
int length () const
 return size of used memory More...
 
T & operator[] (int i)
 [] array access operators More...
 
const T & operator[] (int i) const
 
void disown ()
 resets all members to 0 More...
 
void shrink (int i)
 shrink vector memory size AND DELETE UNUSED MEMORY More...
 
void setsize (int i)
 shrink vector memory size More...
 
void deletecontents ()
 
void deletearrays ()
 
T * getbuf ()
 get the whole vector More...
 
const T * getbuf () const
 get the whole vector as const value More...
 
bool inbuf (const T *e) const
 
template<class F >
void sort (F fun, int i=0, int n=-1)
 sort the vector using quicksort template and sort criteria F More...
 
void sort ()
 
void sortname ()
 
void shuffle ()
 mix the vector's indices randomly More...
 
void growbuf (int sz)
 reallocate memory for vector (its size) More...
 
databuf< T > reserve (int sz)
 reserved memory and returns vector of the reserved memory More...
 
void advance (int sz)
 increase value of used bytes manually (?) More...
 
void addbuf (const databuf< T > &p)
 increase value of used bytes by size of a vector More...
 
T * pad (int n)
 
void put (const T &v)
 write bytes to vector More...
 
void put (const T *v, int n)
 
void remove (int i, int n)
 remove indices from vector remove ordered? More...
 
remove (int i)
 remove element from given position. More...
 
removeunordered (int i)
 
template<class U >
int find (const U &o)
 find (first) index in vector. More...
 
void addunique (const T &o)
 only add new element if it is unique. More...
 
void removeobj (const T &o)
 remove an element if equal to to given one. More...
 
void replacewithlast (const T &o)
 replace an index with the last vector index using a template parameter key More...
 
T & insert (int i, const T &e)
 insertion functions More...
 
T * insert (int i, const T *e, int n)
 
void reverse ()
 reverse all indices (first becomes last and so on...) More...
 
void buildheap ()
 ? More...
 
int upheap (int i)
 ? More...
 
T & addheap (const T &x)
 ? More...
 
int downheap (int i)
 ? More...
 
removeheap ()
 ? More...
 
template<class K >
int htfind (const K &key)
 similar to find but uses hashtable keys More...
 

Static Public Member Functions

static int heapparent (int i)
 ? More...
 
static int heapchild (int i)
 

Public Attributes

T * buf
 data pointer More...
 
int alen
 ALLOCATED memory size. More...
 
int ulen
 USED memory size. More...
 

Detailed Description

template<class T, int MINSIZE = 8>
struct vector< T, MINSIZE >

Vector template.

a manual implementation of vector templates (self managing dynamic arrays which store one type).

Constructor & Destructor Documentation

template<class T, int MINSIZE = 8>
vector< T, MINSIZE >::vector ( )
inline

Default constructor.

sets all members to 0

template<class T, int MINSIZE = 8>
vector< T, MINSIZE >::vector ( const vector< T, MINSIZE > &  v)
inline

Copy constructor.

this constructor initialises the vector by copying another vector.

Parameters
vthe vector from which data will be copied (call by reference).
template<class T, int MINSIZE = 8>
vector< T, MINSIZE >::~vector ( )
inline

Destructor.

Deletes all allocated memory and sets vector size to 0.

Member Function Documentation

template<class T, int MINSIZE = 8>
T& vector< T, MINSIZE >::add ( const T &  x)
inline

Add new index to vector.

Pushs a new element at the end of the vector. Allocates memory automaticly if neccesary.

Parameters
xElement which will be added at the end May allocates a lot of memory without your notice
See Also
growbuf
Returns
The last element of the vector (which is parameter x)

Referenced by ai::avoidset::add(), aiman::addai(), addbatchedmodel(), addblendbrush(), addchange(), ctfmode::addflag(), addglobalparam(), addgrasstri(), addident(), addlight(), addlocalparam(), addname(), addnormal(), addpackagedir(), addreflection(), addskyverts(), addsleep(), addslotparam(), addtjoint(), addtnormal(), addtris(), addvbo(), verthash::addvert(), addwaterfallrefraction(), game::ctfclientmode::aicheck(), game::captureclientmode::aidefend(), game::ctfclientmode::aidefend(), game::captureclientmode::aifind(), game::collectclientmode::aifind(), game::ctfclientmode::aifind(), ai::anynode(), ai::assist(), server::autoteam(), aiman::balanceteams(), ai::wpcache::build(), server::buildworldstate(), skelmodel::skeleton::calcantipodes(), aiman::calcteams(), changedvars(), checkdynentcache(), checklightcache(), server::checklms(), server::checkmaps(), ai::checkothers(), ai::checkroute(), server::checkvotes(), editor::clear(), compileblock(), compileblockstr(), compileblocksub(), compilefloat(), compileident(), compileint(), compilelookup(), compilemain(), compilenull(), compilestatements(), compilestr(), compileval(), compileword(), conc(), editor::copyselectionto(), editor::del(), destroyva(), editor::editor(), endmodelbatches(), entadd(), escapestring(), explodelist(), server::extinfoteams(), filltexlist(), findanims(), findents(), findwaterplanes(), fonttex(), format(), genattriblocs(), animmodel::mesh::genBIH(), gencombinedname(), gencubeedges(), gengrassquads(), genlightmaptexs(), genmatsurfs(), genmergedfaces(), genprefabmesh(), genreservedlightmaptexs(), genskyfaces(), genuniformlocs(), vertmodel::vertmesh::genvbo(), skelmodel::skelmesh::genvbo(), md2::md2meshgroup::genverts(), pvsworker::genviewcell(), server::hideandseekservermode::getactiveplayers(), game::getbestplayers(), game::getbestteams(), collectmode_common::getteamscores(), ctfmode::getteamscores(), capturemode_common::getteamscores(), game::groupplayers(), applymenu::gui(), guibutton(), guiimage(), guilistslider(), guimodelpreview(), guinameslider(), guiplayerpreview(), guiprefabpreview(), game::ignore(), game::initclient(), game::listclients(), listdel(), listdir(), listfilter(), listsplice(), obj::objmeshgroup::load(), editor::load(), load_world(), md5::md5meshgroup::loadanim(), loadents(), md5::md5meshgroup::loadmesh(), loadmodel(), Slot::loadthumbnail(), loadvslot(), loopconc(), looplistconc(), mergepolys(), mergetexs(), mergevslot(), mmodel(), modifyoctaent(), modifyoctaentity(), moveplatform(), mpeditvslot(), game::newclient(), newentity(), newfont(), game::newprojectile(), newshader(), newva(), vacollect::optimize(), packvslots(), server::parsepacket(), server::bombservermode::parsespawnloc(), obj::objmeshgroup::parsevert(), pasteundoent(), game::ctfclientmode::pickholdspawn(), precachetextures(), preloadmodel(), preloadusedmapmodels(), prettylist(), propagatevslot(), pushfont(), pushgui(), ai::randomlink(), smd::smdmeshgroup::readnodes(), smd::smdmeshgroup::readtriangles(), vacollect::remapunlit(), ai::remapwaypoints(), renderalphageom(), rendercube(), rendermodel(), renderva(), ai::route(), runcode(), game::saveragdoll(), searchbinds(), editor::selectiontostring(), game::bombclientmode::senditems(), server::bombservermode::sendspawnlocs(), skelcommands< MDL >::setanimpart(), setslotshader(), server::bombservermode::setup(), setupmaterials(), sortlist(), sortmaterials(), strreplace(), ai::target(), ai::tryitem(), unpackvslot(), server::collectservermode::update(), updatedynentcache(), updateva(), updateval(), useeditor(), vshaderparam(), writebinds(), writecfg(), writecompletions(), and writeobj().

template<class T, int MINSIZE = 8>
T& vector< T, MINSIZE >::add ( )
inline

Add new EMPTY index to vector.

Pushs a new EMPTY element at the end of the vector. Allocates memory automaticly if neccesary.

See Also
growbuf May allocates a lot of memory without your notice.
Returns
The last element of the vector (which is parameter x).

Referenced by vector< facebounds >::addheap(), vector< facebounds >::addunique(), vector< facebounds >::insert(), vector< facebounds >::operator=(), and vector< facebounds >::put().

template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::addbuf ( const databuf< T > &  p)
inline

increase value of used bytes by size of a vector

Referenced by vector< facebounds >::put(), and smd::smdmeshgroup::readframes().

template<class T, int MINSIZE = 8>
T& vector< T, MINSIZE >::addheap ( const T &  x)
inline

?

Referenced by ai::route().

template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::addunique ( const T &  o)
inline

only add new element if it is unique.

template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::advance ( int  sz)
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::buildheap ( )
inline

?

template<class T, int MINSIZE = 8>
int vector< T, MINSIZE >::capacity ( ) const
inline

return size of reserved memory

template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::deletearrays ( )
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::deletecontents ( )
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::disown ( )
inline

resets all members to 0

Warning
This member does NOT clean up its memory!

Referenced by callcommand(), execute(), executeret(), and runcode().

template<class T, int MINSIZE = 8>
int vector< T, MINSIZE >::downheap ( int  i)
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::drop ( )
inline

decrement vector's size and call the DESTRUCTOR of the template in the last index

call template's destructor

Referenced by server::buildworldstate(), game::getbestplayers(), game::getbestteams(), and vector< facebounds >::shrink().

template<class T, int MINSIZE = 8>
T& vector< T, MINSIZE >::dup ( )
inline

Duplicate vector's last index.

Duplicates last index of the vector and appends it to the end. Allocates memory automaticly if neccesary.

See Also
growbuf
Note
May allocates a lot of memory without your notice.
Returns
The last element of the vector.
template<class T, int MINSIZE = 8>
bool vector< T, MINSIZE >::empty ( ) const
inline
template<class T, int MINSIZE = 8>
template<class U >
int vector< T, MINSIZE >::find ( const U &  o)
inline
template<class T, int MINSIZE = 8>
T* vector< T, MINSIZE >::getbuf ( )
inline
template<class T, int MINSIZE = 8>
const T* vector< T, MINSIZE >::getbuf ( ) const
inline

get the whole vector as const value

template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::growbuf ( int  sz)
inline
template<class T, int MINSIZE = 8>
static int vector< T, MINSIZE >::heapchild ( int  i)
inlinestatic
template<class T, int MINSIZE = 8>
static int vector< T, MINSIZE >::heapparent ( int  i)
inlinestatic
template<class T, int MINSIZE = 8>
template<class K >
int vector< T, MINSIZE >::htfind ( const K &  key)
inline

similar to find but uses hashtable keys

Referenced by aiman::calcteams(), server::extinfoteams(), and game::getbestteams().

template<class T, int MINSIZE = 8>
bool vector< T, MINSIZE >::inbuf ( const T *  e) const
inline
template<class T, int MINSIZE = 8>
bool vector< T, MINSIZE >::inrange ( size_t  i) const
inline
template<class T, int MINSIZE = 8>
bool vector< T, MINSIZE >::inrange ( int  i) const
inline

safety check: tests if index i exists in this vector integer version: i must be greater (or equal to) 0

template<class T, int MINSIZE = 8>
T& vector< T, MINSIZE >::insert ( int  i,
const T &  e 
)
inline
template<class T, int MINSIZE = 8>
T* vector< T, MINSIZE >::insert ( int  i,
const T *  e,
int  n 
)
inline
template<class T, int MINSIZE = 8>
T& vector< T, MINSIZE >::last ( )
inline
template<class T, int MINSIZE = 8>
int vector< T, MINSIZE >::length ( ) const
inline

return size of used memory

Referenced by ai::avoidset::add(), addbatchedmodel(), addblendbrush(), addchange(), ctfmode::addflag(), addlocalparam(), server::addmaprotations(), server::addmessages(), addnormal(), server::addposition(), addskyverts(), addtjoint(), addtnormal(), Shader::addvariant(), verthash::addvert(), game::ctfclientmode::aicheck(), aiman::balanceteams(), BIH::BIH(), ai::wpcache::build(), server::buildworldstate(), animmodel::part::calcanim(), skelmodel::skeleton::calcantipodes(), ragdolldata::calcboundsphere(), pvsworker::calcpvs(), aiman::calcteams(), server::bombservermode::canspawn(), server::checklms(), server::checkmaps(), ai::checkroute(), aiman::chooseteam(), clearblendbrushes(), cleargui(), clearguis(), commitchanges(), geombatch::compare(), comparevslot(), compileblock(), compileblockstr(), compilecode(), compileval(), editor::copyselectionto(), currentfocus(), editor::currentline(), editor::del(), delblendbrush(), editor::draw(), edittex_(), game::edittrigger(), endmodelbatches(), endmodelquery(), enlargemap(), entautoview(), explodelist(), filltexlist(), smd::smdmeshgroup::smdmeshdata::finalize(), ai::findassist(), finddynlights(), findentity(), findlights(), findreflectedvas(), findvisiblevas(), findwaterplanes(), server::flushclientposition(), flushpreloadedmodels(), flushvbo(), fontalias(), fonttex(), g3d_key(), gencubeedges(), generategrass(), gengrassquads(), genlightmaptexs(), genpvs(), genreservedlightmaptexs(), vertmodel::vertmesh::genvbo(), skelmodel::skelmesh::genvbo(), vertmodel::vertmeshgroup::genvbo(), skelmodel::skelmeshgroup::genvbo(), md2::md2meshgroup::genverts(), pvsworker::genviewcell(), game::getbestplayers(), game::getbestteams(), getselpos(), guilistslider(), guimodelpreview(), guinameslider(), inexor::sound::soundconfig::hasslot(), haveselent(), editor::hit(), ai::hunt(), server::ctfservermode::initclient(), server::hideandseekservermode::initplayers(), editor::insert(), editor::insertallfrom(), game::iterdynents(), editor::key(), editor::limitscrolly(), listdel(), listfilter(), listsplice(), obj::objmeshgroup::load(), md2::md2meshgroup::load(), editor::load(), md5::md5meshgroup::loadanim(), smd::smdmeshgroup::loadanim(), md5::md5meshgroup::loadmesh(), smd::smdmeshgroup::loadmesh(), loopconc(), looplistconc(), ai::makeroute(), mapmodelreset(), menuprocess(), mergepolys(), mergetexs(), ragdolldata::move(), moveplatform(), mpeditent(), mpeditvslot(), game::newclient(), newentity(), newundoent(), nextblendbrush(), game::nextfollow(), game::numdynents(), vector< facebounds >::operator=(), vacollect::optimize(), packeditinfo(), packundo(), ai::parseinterests(), pasteundoent(), game::ctfclientmode::pickholdspawn(), precachetextures(), preloadusedmapmodels(), pushgui(), pvsstats(), queryreflections(), ai::randomlink(), ai::randomnode(), smd::smdmeshgroup::readtriangles(), editor::region(), game::removeprojectiles(), ai::render(), renderalphageom(), rendercube(), renderentselection(), rendergeom(), rendergeommultipass(), rendermodel(), renderreflectedskyvas(), game::renderscoreboard(), renderva(), restoregui(), save_world(), savepvs(), savevslot(), game::scoregroupcmp(), searchbinds(), editor::selectiontostring(), game::bombclientmode::senditems(), game::ctfclientmode::senditems(), game::sendmessages(), game::sendpositions(), server::bombservermode::sendspawnlocs(), server::servercompatible(), skelcommands< MDL >::setanimpart(), server::ctfservermode::setup(), game::ctfclientmode::setup(), vacollect::setupdata(), server::ctfservermode::setupholdspawns(), setupmaterials(), ragdollskel::setuprotfrictions(), setva(), shader(), shrinkmap(), sortlist(), strreplace(), vacollect::texsort(), ragdolldata::tryunstick(), server::collectservermode::update(), updateva(), variantshader(), and writeobj().

template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::move ( vector< T > &  v)
inline

copy vector from vector reference

Referenced by vacollect::setupdata(), and updateva().

template<class T, int MINSIZE = 8>
vector<T>& vector< T, MINSIZE >::operator= ( const vector< T > &  v)
inline

Operator =.

Resets own memory and copies all data from the other vector.

Parameters
vThe vector from which data will be copied.
Returns
Returns a pointer to itself.
template<class T, int MINSIZE = 8>
T& vector< T, MINSIZE >::operator[] ( int  i)
inline

[] array access operators

template<class T, int MINSIZE = 8>
const T& vector< T, MINSIZE >::operator[] ( int  i) const
inline
template<class T, int MINSIZE = 8>
T* vector< T, MINSIZE >::pad ( int  n)
inline
template<class T, int MINSIZE = 8>
T& vector< T, MINSIZE >::pop ( )
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::put ( const T &  v)
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::put ( const T *  v,
int  n 
)
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::remove ( int  i,
int  n 
)
inline
template<class T, int MINSIZE = 8>
T vector< T, MINSIZE >::remove ( int  i)
inline

remove element from given position.

Returns
the removed element.
template<class T, int MINSIZE = 8>
T vector< T, MINSIZE >::removeheap ( )
inline

?

Referenced by ai::route().

template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::removeobj ( const T &  o)
inline
template<class T, int MINSIZE = 8>
T vector< T, MINSIZE >::removeunordered ( int  i)
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::replacewithlast ( const T &  o)
inline

replace an index with the last vector index using a template parameter key

template<class T, int MINSIZE = 8>
databuf<T> vector< T, MINSIZE >::reserve ( int  sz)
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::reverse ( )
inline

reverse all indices (first becomes last and so on...)

template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::setsize ( int  i)
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::shrink ( int  i)
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::shuffle ( )
inline

mix the vector's indices randomly

Referenced by server::bombservermode::sendspawnlocs().

template<class T, int MINSIZE = 8>
template<class F >
void vector< T, MINSIZE >::sort ( fun,
int  i = 0,
int  n = -1 
)
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::sort ( )
inline
template<class T, int MINSIZE = 8>
void vector< T, MINSIZE >::sortname ( )
inline

Referenced by changedvars(), writebinds(), and writecfg().

template<class T, int MINSIZE = 8>
int vector< T, MINSIZE >::upheap ( int  i)
inline

Member Data Documentation

template<class T, int MINSIZE = 8>
int vector< T, MINSIZE >::alen
template<class T, int MINSIZE = 8>
T* vector< T, MINSIZE >::buf
template<class T, int MINSIZE = 8>
int vector< T, MINSIZE >::ulen

The documentation for this struct was generated from the following file: