PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PList.h
Go to the documentation of this file.
1//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3// Name: src/base/PList.h
4// Purpose: Contains declaration for the list structure.
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2003-2026 Shane T. Mueller <smueller@obereed.net>
7// License: GPL 2
8//
9//
10//
11// This file is part of the PEBL project.
12//
13// PEBL is free software; you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation; either version 2 of the License, or
16// (at your option) any later version.
17//
18// PEBL is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU General Public License for more details.
22//
23// You should have received a copy of the GNU General Public License
24// along with PEBL; if not, write to the Free Software
25// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27#ifndef __PLIST_H__
28#define __PLIST_H__
29
30#include "Variant.h"
31#include "../utility/rc_ptrs.h"
32#include "PEBLObject.h"
33
34//#include <list>
35#include <vector>
36#include <iostream>
37
38
39class Variant;
40
44class PList: public PEBLObjectBase
45{
46
47public:
48
49 PList();
50 PList(int reservedsize);
51
52 virtual ~PList();
53
55 // PList(PList & list);
56 PList(const PList & tmpList);
58 virtual PList * Clone();
59
60 std::vector<Variant>::const_iterator Begin() const;
61 std::vector<Variant>::const_iterator End() const;
62
63 std::vector<Variant>::iterator Begin();
64 std::vector<Variant>::iterator End() ;
65
66 // std::list<Variant>::iterator GetNext(std::list<Variant>::iterator i){return i->next(); }
67 // std::list<Variant>::iterator GetPrev(std::list<Variant>::iterator i){return i->previous(); }
68 // void PushFront(const Variant & v);
69 // void PopFront();
70 void PushBack(const Variant & v);
71 void PopBack();
72
73
74 bool IsEmpty(){return mList.empty();};
75 // void Remove(Variant v){mList.remove(v);};
76 void Clear(){mList.clear();};
77
78 Variant First();
80 Variant Nth(unsigned int n);
81 Variant Last();
83
84 //For some unknown reason emscripten produces an off-by-one error here.
85 //#ifdef PEBL_EMSCRIPTEN
86 // unsigned int Length()const; //full definition in .cpp file
87 //#else
88 //#endif
89 unsigned long Length()const{return mList.size();}
90
92
93 void SetElement(unsigned int n,Variant value);
94
95 //std::vector<Variant> * GetList();
96 const std::vector<Variant> * GetList()const {return &mList;};
97
98 //Overload of the << operator
99 friend std::ostream & operator <<(std::ostream & out, const PList & pcd );
100
101
102
103protected:
104 std::ostream & SendToStream(std::ostream& out) const;
105
106private:
107 std::vector<Variant> mList;
108};
109
110
111#endif
Definition PList.h:45
std::vector< Variant >::const_iterator End() const
Definition PList.cpp:132
bool IsEmpty()
Definition PList.h:74
const std::vector< Variant > * GetList() const
Definition PList.h:96
void SetElement(unsigned int n, Variant value)
Definition PList.cpp:222
counted_ptr< PEBLObjectBase > SortBy(const PList &key)
Definition PList.cpp:253
std::vector< Variant >::const_iterator Begin() const
Definition PList.cpp:127
void Clear()
Definition PList.h:76
Variant Nth(unsigned int n)
Definition PList.cpp:181
unsigned long Length() const
Definition PList.h:89
Variant Last()
Definition PList.cpp:235
virtual PList * Clone()
Makes and returns a deep copy–notworking because copy makes deep copy anyway?
Definition PList.cpp:86
bool IsMember(Variant v)
friend std::ostream & operator<<(std::ostream &out, const PList &pcd)
Definition PList.cpp:293
PList()
Standard Constructor.
Definition PList.cpp:48
void PushBack(const Variant &v)
Definition PList.cpp:149
void PopBack()
Definition PList.cpp:162
Variant Rest()
Variant First()
Definition PList.cpp:169
virtual ~PList()
Standard Destructor.
Definition PList.cpp:109
std::ostream & SendToStream(std::ostream &out) const
Definition PList.cpp:305