PList Class Reference

Detailed Description

The PList class represents a generic container which handle an ordered collection of PObject; NOT thread-safe.

You can store different type of Papillon objects in a same list.

PList relies on a resizable-array implementation.

How to iterate over a PList?

PList list;
list.Add(PString("test string"));
// ...
for (int32 i=0, n=list.Size(); i<n; ++i)
{
PString element;
if (list.Get(i, element).Ok())
...
}

To copy the list container, you can use Clone(); warning: you will obtain a separate container but elements themselves are not cloned.

Definition at line 46 of file PList.h.

#include <PList.h>

Constructor & Destructor Documentation

◆ PList() [1/2]

PList::PList ( )

Constructs an empty list.

◆ PList() [2/2]

PList::PList ( const PList other)

Constructs a shared copy of other.

See also
Clone()

◆ ~PList()

virtual PList::~PList ( )
virtual

Destroys this object.

Member Function Documentation

◆ Add()

PList& PList::Add ( const PObject element)

Adds the specified element at the end of this list.

Calls to Add() can be chained.

◆ AddFirst()

PList& PList::AddFirst ( const PObject element)

Adds the specified element at the beginning of this list.

Calls to Add() can be chained.

◆ Append()

PList& PList::Append ( const PList list)

Appends all the elements of the specified list to this list.

◆ Clear()

void PList::Clear ( )

Clears this list.

See also
IsEmpty()

◆ Clone()

PList PList::Clone ( ) const

Returns a copy of this list.

The container is cloned but elements are not.

◆ Contains()

bool PList::Contains ( const PObject element) const

Returns true if the list contains at least an occurrence of the specified element, otherwise returns false.

◆ Get()

PResult PList::Get ( papillon::int32  index,
PObject element 
) const

Gets the element at the specified index; the index must be valid.

Returns PResult::C_OK if success, another result otherwise (e.g. invalid index).

◆ IsEmpty()

bool PList::IsEmpty ( ) const

Returns true if this list of strings is empty, false otherwise.

See also
Size()

◆ operator=()

PList& PList::operator= ( const PList other)

Performs a shared copy of other to this object.

See also
Clone()

◆ Remove()

PResult PList::Remove ( papillon::int32  index)

Removes the nth element in is list, effectively reducing the container size by one.

Returns PResult::C_OK if success, another result otherwise (e.g. if the container is empty).

◆ RemoveFirst()

PResult PList::RemoveFirst ( )

Removes the first element in this list, effectively reducing the container size by one.

Returns PResult::C_OK if success, another result otherwise (e.g. if the container is empty).

◆ RemoveLast()

PResult PList::RemoveLast ( )

Removes the last element in is list, effectively reducing the container size by one.

Returns PResult::C_OK if success, another result otherwise (e.g. if the container is empty).

◆ Set()

PResult PList::Set ( papillon::int32  index,
const PObject element 
) const

Sets the element at the specified index; the index must be valid.

Returns PResult::C_OK if success, another result otherwise (e.g. invalid index).

◆ Size()

papillon::int32 PList::Size ( ) const

Returns the number of elements in this list.

See also
IsEmpty()