Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef ARY_ESTACK_HXX
21 : #define ARY_ESTACK_HXX
22 :
23 :
24 :
25 : // USED SERVICES
26 : // BASE CLASSES
27 : #include <list>
28 : // COMPONENTS
29 : // PARAMETERS
30 :
31 :
32 :
33 : template <class ELEM>
34 : class EStack : private std::list<ELEM>
35 : {
36 : private:
37 : typedef std::list<ELEM> base;
38 : const base & Base() const { return *this; }
39 : base & Base() { return *this; }
40 :
41 : public:
42 : typedef ELEM value_type;
43 : typedef typename std::list<ELEM>::size_type size_type;
44 :
45 : // LIFECYCLE
46 170566 : EStack() {}
47 : EStack(
48 : const EStack & i_rStack )
49 : : base( (const base &)(i_rStack) ) {}
50 170566 : ~EStack() {}
51 : // OPERATORS
52 : EStack & operator=(
53 : const EStack & i_rStack )
54 : { base::operator=( i_rStack.Base() );
55 : return *this; }
56 : bool operator==(
57 : const EStack<ELEM> & ) const
58 : { return std::operator==( Base(), this->i_rStack.Base() ); }
59 : bool operator<(
60 : const EStack<ELEM> & ) const
61 : { return std::operator<( Base(), this->i_rStack.Base() ); }
62 : // OPERATIONS
63 220871 : void push(
64 : const value_type & i_rElem )
65 220871 : { base::push_front(i_rElem); }
66 85046 : void pop() { base::pop_front(); }
67 : void erase_all() { while (NOT empty()) pop(); }
68 :
69 : // INQUIRY
70 1824232 : const value_type & top() const { return base::front(); }
71 : size_type size() const { return base::size(); }
72 : bool empty() const { return base::empty(); }
73 :
74 : // ACCESS
75 : value_type & top() { return base::front(); }
76 : };
77 :
78 :
79 :
80 : // IMPLEMENTATION
81 :
82 :
83 : #endif
84 :
85 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|