Debian Codegraph @

Kernel/SearchableStack.h

raw symbols SCIP
1 /* This file is part of the FaCT++ DL reasoner
2 Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester
3 Copyright (C) 2015-2017 Dmitry Tsarkov
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef SEARCHABLESTACK_H
21 #define SEARCHABLESTACK_H
22
23 // template class for stack with opportunity of search duplicate elements
24 #include <vector>
25
26 template <typename T>
27 class SearchableStack
28 {
29 protected:
30 std::vector<T> Base;
31
32 public:
33 // from vector.h
34 typedef T value_type;
35 typedef typename std::vector<T>::pointer pointer;
36 typedef typename std::vector<T>::const_pointer const_pointer;
37 typedef typename std::vector<T>::iterator iterator;
38 typedef typename std::vector<T>::const_iterator const_iterator;
39 typedef typename std::vector<T>::reference reference;
40 typedef typename std::vector<T>::const_reference const_reference;
41
42 public:
43
44 /*********** constructors **************/
45 SearchableStack ( void ) {}
46 SearchableStack ( const SearchableStack<T>& v ) : Base (v.Base) {}
47
48 SearchableStack& operator = ( const SearchableStack<T>& v )
49 {
50 Base = v.Base;
51 return *this;
52 }
53
54 /*********** iterators **************/
55 iterator begin() { return Base.begin(); }
56 const_iterator begin() const { return Base.begin(); }
57 iterator end() { return Base.end(); }
58 const_iterator end() const { return Base.end(); }
59
60 /*********** stack operations **************/
61 void push ( const T& val ) { Base.push_back(val); }
62 reference top ( void ) { return Base.back(); }
63 const_reference top ( void ) const { return Base.back(); }
64 void pop ( void ) { Base.pop_back(); }
65 /* iterator find ( const T& val ) const
66 {
67 for ( iterator p = begin(); p != end(); ++p )
68 if ( *p == val )
69 return p;
70
71 return end();
72 }*/
73 const_iterator find ( const T& val ) const
74 {
75 for ( const_iterator p = begin(); p != end(); ++p )
76 if ( *p == val )
77 return p;
78
79 return end();
80 }
81 bool contains ( const T& val ) const { return ( find(val) != end() ); }
82 bool empty ( void ) const { return Base.empty (); }
83 }; // SearchableStack
84
85 #endif