GrowingArrayBase Class Reference

#include <tArray.h>

Inheritance diagram for GrowingArrayBase:

Inheritance graph
[legend]

List of all members.

Public Member Functions

void ComplainIfFull ()
void SetLen (int i)
int Len () const
int Size () const

Protected Member Functions

void ResizeBase (int i, int size_of_T, bool useMalloc)
void * Base () const
 GrowingArrayBase (int firstsize, int size_of_T, bool useMalloc)
void Delete (bool useMalloc)
 ~GrowingArrayBase ()

Private Member Functions

const GrowingArrayBaseoperator= (const GrowingArrayBase &)
 GrowingArrayBase (GrowingArrayBase &)

Private Attributes

int len
int size
void * base


Detailed Description

Definition at line 37 of file tArray.h.


Constructor & Destructor Documentation

GrowingArrayBase::GrowingArrayBase ( GrowingArrayBase  )  [private]

GrowingArrayBase::GrowingArrayBase ( int  firstsize,
int  size_of_T,
bool  useMalloc 
) [protected]

Definition at line 45 of file tArray.cpp.

References len, malloc, NULL, size, tERR_ERROR, and tNEW.

00046 {
00047     // dump(low,dump,"con:size " << firstsize << ",element size " << size_of_T);
00048     len=firstsize;
00049     if (firstsize) size=firstsize;
00050     else             size=1;
00051 
00052     if ( useMalloc )
00053         base=malloc(size * size_of_T);
00054     else
00055         base=tNEW( char[size * size_of_T] );
00056 
00057     if(NULL==base) {
00058         tERR_ERROR("Error Allocating " << size_of_T*(size) << " bytes." );
00059     }
00060     for(int i=size*size_of_T-1;i>=0;i--)
00061         (reinterpret_cast<char *>(base))[i]=0;
00062 
00063 }

GrowingArrayBase::~GrowingArrayBase (  )  [protected]

Definition at line 65 of file tArray.cpp.

References NULL, and tASSERT.

00065                                    {
00066     tASSERT( base == NULL );
00067     // dump(very_low,flow,"des");
00068 }


Member Function Documentation

const GrowingArrayBase& GrowingArrayBase::operator= ( const GrowingArrayBase  )  [private]

void GrowingArrayBase::ResizeBase ( int  i,
int  size_of_T,
bool  useMalloc 
) [protected]

Definition at line 85 of file tArray.cpp.

References free, malloc, NULL, size, tERR_ERROR, and tNEW.

Referenced by tArray< uSelectItem< tString > *, false >::resize().

00085                                                                     {
00086 
00087     i++;
00088 
00089     // dump(very_low,flow,"Array-base resize");
00090 
00091     unsigned int oldsize=size;
00092 
00093     int size_a=i+(1<<12);
00094     int size_b=i+(i>>2);
00095 
00096     int new_size;
00097 
00098     if (size_a<size_b)
00099         new_size=size_a;
00100     else
00101         new_size=size_b;
00102 
00103     //  void *newbase=NULL;//realloc(base,size_of_T*(size));
00104     //  void *newbase=realloc(base,size_of_T*(size));
00105     //  if(NULL==newbase){
00106 
00107     void *newbase;
00108     if ( useMalloc )
00109         newbase = malloc(new_size * size_of_T);
00110     else
00111         newbase=tNEW( char[new_size * size_of_T] );
00112 
00113 
00114     if(NULL==newbase){
00115         tERR_ERROR("Error reallocating " << size_of_T*(new_size) << " bytes.");
00116     }
00117     else{
00118         memcpy(newbase,base,size_of_T*(oldsize));
00119         if ( useMalloc )
00120         {
00121             free(base);
00122         }
00123         else
00124         {
00125             delete[] (char*)base;
00126         }
00127     }
00128     //
00129     size = new_size;
00130 
00131     // clear the newly allocated memory
00132     char *start=(reinterpret_cast<char *>(newbase)) + oldsize*size_of_T;
00133     for(int j=(size-oldsize)*size_of_T-1;j>=0;j--)
00134         start[j]=0;
00135 
00136     base=newbase;
00137 }

Here is the caller graph for this function:

void* GrowingArrayBase::Base (  )  const [inline, protected]

Definition at line 47 of file tArray.h.

Referenced by tArray< uSelectItem< tString > *, false >::Clear(), tArray< uSelectItem< tString > *, false >::CopyFrom(), tArray< uSelectItem< tString > *, false >::Init(), tArray< uSelectItem< tString > *, false >::operator()(), tArray< uSelectItem< tString > *, false >::operator+(), tArray< uSelectItem< tString > *, false >::operator[](), and tArray< uSelectItem< tString > *, false >::resize().

00047 {return base;}

Here is the caller graph for this function:

void GrowingArrayBase::Delete ( bool  useMalloc  )  [protected]

Definition at line 70 of file tArray.cpp.

References free, len, NULL, and size.

Referenced by tArray< uSelectItem< tString > *, false >::Clear(), and tArray< uSelectItem< tString > *, false >::~tArray().

00070                                              {
00071     // dump(very_low,flow,"des");
00072     if ( useMalloc )
00073     {
00074         free(base);
00075     }
00076     else
00077     {
00078         delete[] (char*)base;
00079     }
00080 
00081     base = NULL;
00082     size = len = 0;
00083 }

Here is the caller graph for this function:

void GrowingArrayBase::ComplainIfFull (  ) 

Definition at line 40 of file tArray.cpp.

References Len(), and tERR_ERROR.

00040                                      {
00041     if (Len()>0)
00042         tERR_ERROR("Array should be empty.");
00043 }

Here is the call graph for this function:

void GrowingArrayBase::SetLen ( int  i  )  [inline]

Reimplemented in tArray< T, MALLOC >, tArray< tCONTROLLED_PTR(eVoter) >, tArray< const gCycle * >, tArray< gCycleMemoryEntry *, false >, tArray< double >, tArray< eWall *, false >, tArray< uSelectItem< bool > *, false >, tArray< uSelectItem< rScreenSize > *, false >, tArray< eGameObject *, false >, tArray< eFace *, MALLOC >, tArray< tStatEntry *, false >, tArray< tString >, tArray< float >, tArray< ePoint *, MALLOC >, tArray< T *, MALLOC >, tArray< Vec3 >, tArray< nBandwidthArbitrator *, MALLOC >, tArray< unsigned int >, tArray< gAICharacter >, tArray< eCoord >, tArray< uSelectItem< int > *, false >, tArray< unsigned short >, tArray< gSpawnPoint *, false >, tArray< eHalfEdge *, MALLOC >, tArray< ePlayerNetID *, false >, tArray< tHeapElement *, false >, tArray< tControlledPTR< T > >, tArray< rModelFace >, tArray< gPlayerWallCoord >, tArray< eVoter *, false >, tArray< uSelectItem< Vote > *, false >, tArray< memblock *, MALLOC >, tArray< rITexture *, false >, tArray< eTeam *, false >, tArray< eVoteItem *, false >, tArray< uSelectItem< T > *, false >, tArray< uMenuItem *, false >, tArray< eCamera *, false >, and tArray< uSelectItem< tString > *, false >.

Definition at line 63 of file tArray.h.

References len.

Referenced by tArray< uSelectItem< tString > *, false >::SetLen().

00063 {len=i;}

Here is the caller graph for this function:

int GrowingArrayBase::Len (  )  const [inline]

Reimplemented in tHeapBase, tHeap< T >, tHeap< nBandwidthArbitrator >, and tHeap< tEvent >.

Definition at line 64 of file tArray.h.

References len.

Referenced by tReferenceHolder< T >::Add(), tList< uSelectItem< Vote > >::Add(), nSendBuffer::AddMessage(), eTeam::AddPlayer(), eTeam::AddScore(), eTeam::Alive(), eTeam::AlivePlayers(), tMemManager::Alloc(), gGame::Analysis(), gAITeam::BalanceWithAIs(), BestIQ(), gNetPlayerWall::BlowHole(), nSendBuffer::Broadcast(), gNetPlayerWall::Check(), tMemManager::Check(), eGrid::Check(), tMemManager::CheckHeap(), CheckLoop(), gNetPlayerWall::Checkpoint(), gBaseZoneHack::CheckSurvivor(), uMenuItemSelection< bool >::Clear(), gNetPlayerWall::Clear(), gCycleMemory::Clear(), nSendBuffer::Clear(), eGrid::Clear(), clear_owners(), nNetObject::ClearAll(), ClearKnows(), CompareBufferToPlayerNames(), ComplainIfFull(), tArray< uSelectItem< tString > *, false >::CopyFrom(), gBaseZoneHack::CountZonesOfTeam(), eLineEntry::Create(), eHalfEdge::CrossesNewWall(), nMessage::DataLen(), eLineEntry::Delete(), eGameObject::DeleteAll(), eGrid::display_simple(), do_chat(), rConsole::DoPrint(), nServerInfo::DoQueryAll(), cWidget::Map::DrawObjects(), cWidget::Map::DrawRimWalls(), cWidget::Map::DrawWalls(), gCycleMemory::Earliest(), gAIPlayer::EmergencySurvive(), nMessage::End(), gNetPlayerWall::EndPos(), gNetPlayerWall::EndTime(), eTeam::Enemies(), eTeam::Enforce(), gMenuItemPlayer::Enter(), eVoteItem::Evaluate(), exit_game_objects(), fill_audio(), eGrid::FindSurroundingFace(), tStatFile::flushWrites(), gAIPlayer::gAIPlayer(), GameLoop(), gGame::GameLoop(), eTeam::GetAllMembers(), tDirectories::GetFiles(), uMenu::GetNextSelectable(), tPath::GetPaths(), gStatList::getPlaceInList(), uMenu::GetPrevSelectable(), tPath::GetReadPath(), eVoteItem::GetStats(), gServerInfoAdmin::GetUsers(), eVoter::GetVoter(), tPath::GetWritePath(), ePath::GoBack(), gServerMenu::gServerMenu(), gNetPlayerWall::IndexPos(), init_exp(), init_game_objects(), tMemManager::Insert(), tArray< uSelectItem< tString > *, false >::Insert(), IsTrapped(), eVoter::KickMenu(), kill_id_hog(), gCycleMemory::Latest(), gArena::LeastDangerousSpawnPoint(), uMenuItemSelection< bool >::LeftRight(), gCycleMemory::Len(), tHeapBase::Len(), nSendBuffer::Len(), rModel::Load(), rITexture::LoadAll(), LoadSingleAI(), ePlayerNetID::LogScoreDifferences(), main(), gNetPlayerWall::MyInitAfterCreation(), eVoter::Name(), net_destroy_handler(), eTeam::NewTeamAllowed(), eGrid::NumberOfCameras(), uMenu::NumItems(), eTeam::NumPlayers(), eTeam::OldestAIPlayer(), eTeam::OldestHumanPlayer(), eTeam::OldestPlayer(), uMenu::OnEnter(), gExplosion::OnNewWall(), tPath::Open(), tArray< uSelectItem< tString > *, false >::operator()(), tArray< uSelectItem< tString > *, false >::operator+(), tArray< uSelectItem< tString > *, false >::operator=(), nMessage::operator>>(), tArray< uSelectItem< tString > *, false >::operator[](), PasswordCallback(), eTeam::PlayerMayJoin(), gArena::PrepareGrid(), PrepareTeamText(), eGrid::ProcessWallsInRange(), eTeam::Ranking(), ePlayerNetID::Ranking(), eTeam::RankingGraph(), gNetPlayerWall::ReadSync(), eTeam::ReadSync(), tSettingRotation::ReadVal(), tConfItemPassword::ReadVal(), gNetPlayerWall::real_Update(), rec_peer(), nNetObject::RelabelOnConnect(), tReferenceHolder< T >::ReleaseAll(), gCycleMemory::Remember(), tReferenceHolder< T >::Remove(), tMemManager::Remove(), tList< uSelectItem< Vote > >::Remove(), gArena::RemoveAllSpawn(), tArray< uSelectItem< tString > *, false >::RemoveAt(), ePlayerNetID::RemoveChatbots(), eTeam::RemovePlayer(), eTeam::RemovePlayerDirty(), uMenuItemSelection< bool >::Render(), gExplosion::Render(), rModel::Render(), eDebugLine::Render(), gExplosion::Render2D(), eGameObject::RenderAll(), eWallRim::RenderAll(), RenderAllViewports(), gNetPlayerWall::RenderList(), tMemManager::Replace(), ePlayerNetID::RequestScheduledLogins(), ePlayerNetID::ResetScoreDifferences(), uMenu::ReverseItems(), tSettingRotation::Rotate(), gNetPlayerWall::s_CopyIntoGrid(), eVoteItemServerControlled::s_HandleChanged(), eGameObject::s_Timestep(), eCamera::s_Timestep(), nServerInfo::Save(), se_CancelAllVotes(), se_ChatMsg(), se_ChatState(), se_ChatTeam(), se_Cleanup(), se_GetAccessLevel(), se_GetAlivePlayerFromUserID(), se_GetLocalPlayer(), se_IsNameTaken(), se_ListPlayers(), se_SetWatchedObject(), zSelectorAnotherNotTeammateDead::select(), zSelectorAllDead::select(), zSelectorAnyDead::select(), zSelectorAnother::select(), zSelectorAllButSelf::select(), zSelectorAll::select(), nMessage::Send(), nSendBuffer::Send(), nMessage::SendImmediately(), gNetPlayerWall::SetEndPos(), gNetPlayerWall::SetEndTime(), gAIPlayer::SetNumberOfAIs(), cCockpit::SetPlayer(), sg_FullscreenMessage(), sg_NumHumans(), eTeam::Shuffle(), ePlayerNetID::SilenceMenu(), eGrid::SimplifyAll(), eGrid::SimplifyNum(), tSettingRotation::Size(), sn_DoDestroy(), eTeam::SortByScore(), ePlayerNetID::SortByScore(), tDirectories::SortFiles(), st_DoToDo(), st_ToDo(), nServerInfo::StartQueryAll(), gGame::StateUpdate(), stc_updateFastest(), ePlayerNetID::SwapPlayersNo(), eTeam::SwapTeamsNo(), tMemManager::SwapUp(), nNetObject::SyncAll(), gTeam::TeamMenu(), gAIPlayer::Think(), gAIPlayer::ThinkSurvive(), gAIPlayer::ThinkTrace(), gBaseZoneHack::Timestep(), nBandwidthArbitrator::Timestep(), rITexture::UnloadAll(), gServerMenu::Update(), ePlayerNetID::Update(), eDebugLine::Update(), eTeam::UpdateAppearance(), eWallRim::UpdateBounds(), eTeam::UpdateProperties(), eTeam::UpdateStaticFlags(), ePath::Valid(), eVoter::VotingMenu(), eVoter::VotingPossible(), ePlayerNetID::WaitToLeaveChat(), nMessage::Write(), gNetPlayerWall::WriteSync(), tConfItemPassword::WriteVal(), eTeam::YoungestAIPlayer(), eTeam::YoungestHumanPlayer(), eTeam::YoungestPlayer(), eTeam::~eTeam(), gArena::~gArena(), gServerMenu::~gServerMenu(), gStatList::~gStatList(), tMemManager::~tMemManager(), and uMenu::~uMenu().

00064 {return len;}

int GrowingArrayBase::Size (  )  const [inline]

Definition at line 65 of file tArray.h.

References size.

Referenced by tArray< uSelectItem< tString > *, false >::Clear(), tArray< uSelectItem< tString > *, false >::CopyFrom(), tArray< uSelectItem< tString > *, false >::Init(), tArray< uSelectItem< tString > *, false >::resize(), and tArray< uSelectItem< tString > *, false >::SetLen().

00065 {return size;}

Here is the caller graph for this function:


Member Data Documentation

int GrowingArrayBase::len [private]

Definition at line 38 of file tArray.h.

Referenced by Delete(), GrowingArrayBase(), Len(), and SetLen().

int GrowingArrayBase::size [private]

Definition at line 39 of file tArray.h.

Referenced by Delete(), GrowingArrayBase(), ResizeBase(), and Size().

void* GrowingArrayBase::base [private]

Definition at line 40 of file tArray.h.


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:44:49 2008 for Armagetron Advanced by  doxygen 1.5.4