Nugget
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
eastl::linked_array< T, Deleter > Class Template Reference

#include <linked_array.h>

Collaboration diagram for eastl::linked_array< T, Deleter >:
Collaboration graph
[legend]

Public Types

typedef T element_type
 
typedef T *(this_type::* bool_) () const
 

Public Member Functions

 linked_array (T *pArray=NULL)
 
 linked_array (const linked_array &linkedArray)
 
 ~linked_array ()
 
linked_arrayoperator= (const linked_array &linkedArray)
 
linked_arrayoperator= (T *pArray)
 
void reset (T *pArray=NULL)
 
T & operator[] (ptrdiff_t i) const
 
T & operator* () const
 
T * operator-> () const
 
T * get () const
 
int use_count () const
 
bool unique () const
 
 operator bool_ () const
 
bool operator! ()
 
void force_delete ()
 

Protected Types

typedef linked_array< T > this_type
 
typedef Deleter deleter_type
 deleter_type
 

Protected Member Functions

void link (const linked_array &linkedArray)
 

Protected Attributes

T * mpArray
 
const this_typempPrev
 
const this_typempNext
 

Detailed Description

template<typename T, typename Deleter = smart_array_deleter<T>>
class eastl::linked_array< T, Deleter >

class linked_array

This class implements a linked_array template, which is an array version of linked_ptr. See linked_ptr for detailed documentation.

Member Typedef Documentation

◆ bool_

template<typename T , typename Deleter = smart_array_deleter<T>>
typedef T*(this_type::* eastl::linked_array< T, Deleter >::bool_) () const

Implicit operator bool Allows for using a linked_array as a boolean. Note that below we do not use operator bool(). The reason for this is that booleans automatically convert up to short, int, float, etc. The result is that this: if(linkedArray == 1) would yield true (bad).

◆ element_type

template<typename T , typename Deleter = smart_array_deleter<T>>
typedef T eastl::linked_array< T, Deleter >::element_type

element_type Synonym for type T, useful for external code to reference the type in a generic way.

◆ this_type

template<typename T , typename Deleter = smart_array_deleter<T>>
typedef linked_array<T> eastl::linked_array< T, Deleter >::this_type
protected

this_type This is an alias for linked_array<T>, this class.

Constructor & Destructor Documentation

◆ linked_array() [1/2]

template<typename T , typename Deleter = smart_array_deleter<T>>
eastl::linked_array< T, Deleter >::linked_array ( T *  pArray = NULL)
inlineexplicit

linked_array Takes ownership of the pointer. It is OK if the input pointer is null.

◆ linked_array() [2/2]

template<typename T , typename Deleter = smart_array_deleter<T>>
eastl::linked_array< T, Deleter >::linked_array ( const linked_array< T, Deleter > &  linkedArray)
inline

linked_array Shares ownership of a pointer with another instance of linked_array.

◆ ~linked_array()

template<typename T , typename Deleter = smart_array_deleter<T>>
eastl::linked_array< T, Deleter >::~linked_array ( )
inline

~linked_array Removes this object from the of objects using the shared pointer. If this object is the last owner of the shared pointer, the shared pointer is deleted.

Member Function Documentation

◆ force_delete()

template<typename T , typename Deleter = smart_array_deleter<T>>
void eastl::linked_array< T, Deleter >::force_delete ( )
inline

force_delete Forces deletion of the shared pointer. Fixes all references to the pointer by any other owners to be NULL.

◆ get()

template<typename T , typename Deleter = smart_array_deleter<T>>
T* eastl::linked_array< T, Deleter >::get ( ) const
inline

get Returns the owned pointer. Note that this class does not provide an operator T() function. This is because such a thing (automatic conversion) is deemed unsafe.

◆ operator!()

template<typename T , typename Deleter = smart_array_deleter<T>>
bool eastl::linked_array< T, Deleter >::operator! ( )
inline

operator! This returns the opposite of operator bool; it returns true if the owned pointer is null. Some compilers require this and some don't.

◆ operator*()

template<typename T , typename Deleter = smart_array_deleter<T>>
T& eastl::linked_array< T, Deleter >::operator* ( ) const
inline

operator* Returns the owner pointer dereferenced.

◆ operator->()

template<typename T , typename Deleter = smart_array_deleter<T>>
T* eastl::linked_array< T, Deleter >::operator-> ( ) const
inline

operator-> Allows access to the owned pointer via operator->()

◆ operator=() [1/2]

template<typename T , typename Deleter = smart_array_deleter<T>>
linked_array& eastl::linked_array< T, Deleter >::operator= ( const linked_array< T, Deleter > &  linkedArray)
inline

operator= Copies another linked_array to this object. Note that this object may already own a shared pointer with another different pointer (but still of the same type) before this call. In that case, this function removes ownership of the old pointer and takes shared ownership of the new pointer and increments its reference count.

◆ operator=() [2/2]

template<typename T , typename Deleter = smart_array_deleter<T>>
linked_array& eastl::linked_array< T, Deleter >::operator= ( T *  pArray)
inline

operator= Assigns a new pointer. If the new pointer is equivalent to the current pointer, nothing is done. Otherwise the current pointer is unlinked and possibly destroyed. The new pointer can be NULL.

◆ operator[]()

template<typename T , typename Deleter = smart_array_deleter<T>>
T& eastl::linked_array< T, Deleter >::operator[] ( ptrdiff_t  i) const
inline

swap Exchanges the owned pointer beween two linkedArray objects.

This function is disabled as it is currently deemed unsafe. The problem is that the only way to implement this function is to transfer pointers between the objects; you cannot transfer the linked list membership between the objects. Thus unless both linked_array objects were 'unique()', the shared pointers would be duplicated amongst containers, resulting in a crash. operator[] Returns a reference to the specified item in the owned pointer array.

◆ reset()

template<typename T , typename Deleter = smart_array_deleter<T>>
void eastl::linked_array< T, Deleter >::reset ( T *  pArray = NULL)
inline

reset Releases the owned pointer and takes ownership of the passed in pointer. If the passed in pointer is the same as the owned pointer, nothing is done. The passed in pointer can be null, in which case the use count is set to 1.

◆ unique()

template<typename T , typename Deleter = smart_array_deleter<T>>
bool eastl::linked_array< T, Deleter >::unique ( ) const
inline

unique Returns true if the use count of the owned pointer is one. The return value is true if the owned pointer is null.

◆ use_count()

template<typename T , typename Deleter = smart_array_deleter<T>>
int eastl::linked_array< T, Deleter >::use_count ( ) const
inline

use_count Returns the use count of the shared pointer. The return value is one if the owned pointer is null. This function is provided for compatibility with the proposed C++ standard and for debugging purposes. It is not intended for runtime use given that its execution time is not constant.


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