diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/public/vgui/Dar.h | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/public/vgui/Dar.h')
| -rw-r--r-- | mp/src/public/vgui/Dar.h | 268 |
1 files changed, 134 insertions, 134 deletions
diff --git a/mp/src/public/vgui/Dar.h b/mp/src/public/vgui/Dar.h index b062a26d..ee720085 100644 --- a/mp/src/public/vgui/Dar.h +++ b/mp/src/public/vgui/Dar.h @@ -1,134 +1,134 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: Holds the enumerated list of default cursors
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef DAR_H
-#define DAR_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <vgui/VGUI.h>
-#include "tier1/utlvector.h"
-
-#include "tier0/memdbgon.h"
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Simple lightweight dynamic array implementation
-//-----------------------------------------------------------------------------
-template<class ELEMTYPE> class Dar : public CUtlVector< ELEMTYPE >
-{
- typedef CUtlVector< ELEMTYPE > BaseClass;
-
-public:
- Dar()
- {
- }
- Dar(int initialCapacity) :
- BaseClass( 0, initialCapacity )
- {
- }
-
-public:
- void SetCount(int count)
- {
- this->EnsureCount( count );
- }
- int GetCount()
- {
- return this->Count();
- }
- int AddElement(ELEMTYPE elem)
- {
- return this->AddToTail( elem );
- }
- void MoveElementToEnd( ELEMTYPE elem )
- {
- if ( this->Count() == 0 )
- return;
-
- // quick check to see if it's already at the end
- if ( this->Element( this->Count() - 1 ) == elem )
- return;
-
- int idx = this->Find( elem );
- if ( idx == this->InvalidIndex() )
- return;
-
- this->Remove( idx );
- this->AddToTail( elem );
- }
- // returns the index of the element in the array, -1 if not found
- int FindElement(ELEMTYPE elem)
- {
- return this->Find( elem );
- }
- bool HasElement(ELEMTYPE elem)
- {
- if ( this->FindElement(elem) != this->InvalidIndex() )
- {
- return true;
- }
- return false;
- }
- int PutElement(ELEMTYPE elem)
- {
- int index = this->FindElement(elem);
- if (index >= 0)
- {
- return index;
- }
- return this->AddElement(elem);
- }
- // insert element at index and move all the others down 1
- void InsertElementAt(ELEMTYPE elem,int index)
- {
- this->InsertBefore( index, elem );
- }
- void SetElementAt(ELEMTYPE elem,int index)
- {
- this->EnsureCount( index + 1 );
- this->Element( index ) = elem;
- }
- void RemoveElementAt(int index)
- {
- this->Remove( index );
- }
-
- void RemoveElementsBefore(int index)
- {
- if ( index <= 0 )
- return;
- this->RemoveMultiple( 0, index - 1 );
- }
-
- void RemoveElement(ELEMTYPE elem)
- {
- this->FindAndRemove( elem );
- }
-
- void *GetBaseData()
- {
- return this->Base();
- }
-
- void CopyFrom(Dar<ELEMTYPE> &dar)
- {
- this->CopyArray( dar.Base(), dar.Count() );
- }
-};
-
-}
-
-#include "tier0/memdbgoff.h"
-
-#endif // DAR_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Holds the enumerated list of default cursors +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DAR_H +#define DAR_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <stdlib.h> +#include <string.h> +#include <vgui/VGUI.h> +#include "tier1/utlvector.h" + +#include "tier0/memdbgon.h" + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Simple lightweight dynamic array implementation +//----------------------------------------------------------------------------- +template<class ELEMTYPE> class Dar : public CUtlVector< ELEMTYPE > +{ + typedef CUtlVector< ELEMTYPE > BaseClass; + +public: + Dar() + { + } + Dar(int initialCapacity) : + BaseClass( 0, initialCapacity ) + { + } + +public: + void SetCount(int count) + { + this->EnsureCount( count ); + } + int GetCount() + { + return this->Count(); + } + int AddElement(ELEMTYPE elem) + { + return this->AddToTail( elem ); + } + void MoveElementToEnd( ELEMTYPE elem ) + { + if ( this->Count() == 0 ) + return; + + // quick check to see if it's already at the end + if ( this->Element( this->Count() - 1 ) == elem ) + return; + + int idx = this->Find( elem ); + if ( idx == this->InvalidIndex() ) + return; + + this->Remove( idx ); + this->AddToTail( elem ); + } + // returns the index of the element in the array, -1 if not found + int FindElement(ELEMTYPE elem) + { + return this->Find( elem ); + } + bool HasElement(ELEMTYPE elem) + { + if ( this->FindElement(elem) != this->InvalidIndex() ) + { + return true; + } + return false; + } + int PutElement(ELEMTYPE elem) + { + int index = this->FindElement(elem); + if (index >= 0) + { + return index; + } + return this->AddElement(elem); + } + // insert element at index and move all the others down 1 + void InsertElementAt(ELEMTYPE elem,int index) + { + this->InsertBefore( index, elem ); + } + void SetElementAt(ELEMTYPE elem,int index) + { + this->EnsureCount( index + 1 ); + this->Element( index ) = elem; + } + void RemoveElementAt(int index) + { + this->Remove( index ); + } + + void RemoveElementsBefore(int index) + { + if ( index <= 0 ) + return; + this->RemoveMultiple( 0, index - 1 ); + } + + void RemoveElement(ELEMTYPE elem) + { + this->FindAndRemove( elem ); + } + + void *GetBaseData() + { + return this->Base(); + } + + void CopyFrom(Dar<ELEMTYPE> &dar) + { + this->CopyArray( dar.Base(), dar.Count() ); + } +}; + +} + +#include "tier0/memdbgoff.h" + +#endif // DAR_H |