Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AbstractCollection.h
1 /*
2  * $Id$
3  * AbstractCollection class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2004-08, IRIT UPS.
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #ifndef ELM_DATASTRUCT_ABSTRACTCOLLECTION_H
23 #define ELM_DATASTRUCT_ABSTRACTCOLLECTION_H
24 
25 #include <elm/datastruct/Iterator.h>
26 
27 namespace elm { namespace datastruct {
28 
29 // AbstractCollection class
30 template <class T>
32 public:
33  virtual ~AbstractCollection(void) { }
34  virtual int count(void) = 0;
35  virtual bool contains(const T& item) const = 0;
36  virtual bool isEmpty(void) const = 0;
37  inline operator bool(void) const { return !isEmpty(); }
38  virtual IteratorInst<const T&> *iterator(void) const = 0;
39 };
40 
41 // MutableAbstractCollection class
42 template <class T>
44 public:
45  virtual void clear(void) = 0;
46  virtual void add(const T& item) = 0;
47  virtual void addAll(const AbstractCollection<T>& items) = 0;
48  virtual void remove(const T& item) = 0;
49  virtual void removeAll(const AbstractCollection<T>& items) = 0;
50  virtual void remove(const Iterator<const T&>& iter) = 0;
51 };
52 
53 } } // elm::datastruct
54 
55 #endif // ELM_DATASTRUCT_ABSTRACTCOLLECTION_H
Definition: AbstractCollection.h:31
virtual ~AbstractCollection(void)
Definition: AbstractCollection.h:33
virtual void addAll(const AbstractCollection< T > &items)=0
virtual void removeAll(const AbstractCollection< T > &items)=0
virtual void add(const T &item)=0
Definition: AbstractCollection.h:43
virtual IteratorInst< const T & > * iterator(void) const =0
virtual bool contains(const T &item) const =0
virtual bool isEmpty(void) const =0
Definition: Iterator.h:42