initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / containers / LinkedLists / user / FIFOStack / FIFOStack.H
blobf02afe52eb33eaa8b9d840fd07f682014f202dd6
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::FIFOStack
28 Description
29     A FIFO stack based on a singly-linked list.
30     Operations are push(), pop(), top(), bottom() and empty().
32 SourceFiles
33     FIFOStack.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef FIFOStack_H
38 #define FIFOStack_H
40 #include "SLList.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 /*---------------------------------------------------------------------------*\
48                            Class FIFOStack Declaration
49 \*---------------------------------------------------------------------------*/
51 template<class T>
52 class FIFOStack
54     public SLList<T>
57 public:
59     // Constructors
61         //- Construct null
62         FIFOStack()
63         {}
65         //- Construct given initial T
66         FIFOStack(T a)
67         :
68             SLList<T>(a)
69         {}
71         //- Construct from Istream
72         FIFOStack(Istream& is)
73         :
74             SLList<T>(is)
75         {}
78     // Member Functions
80         // Access
82             //- Return a copy of the top element
83             T top() const
84             {
85                 return this->last();
86             }
88             //- Return a copy of the bottom element
89             T bottom() const
90             {
91                 return this->first();
92             }
95         // Check
97             //- Is the stack empty
98             bool empty() const
99             {
100                 return this->size() == 0;
101             }
104         // Edit
106             //- Push an element onto the stack
107             void push(const T& a)
108             {
109                 this->append(a);
110             }
112             //- Pop the bottom element off the stack
113             T pop()
114             {
115                 return this->removeHead();
116             }
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 } // End namespace Foam
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 #endif
128 // ************************************************************************* //