OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [cxx/] [ustl/] [current/] [include/] [ustl/] [ustack.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// This file is part of the uSTL library, an STL implementation.
2
//
3
// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
4
// This file is free software, distributed under the MIT License.
5
 
6
#ifndef USTACK_H_5242F5635322B2EC44A9AEE73022C6E9
7
#define USTACK_H_5242F5635322B2EC44A9AEE73022C6E9
8
 
9
namespace ustl {
10
 
11
/// \class stack ustack.h ustl.h
12
/// \ingroup Sequences
13
///
14
/// \brief Stack adapter to uSTL containers.
15
///
16
template <typename T>
17
class stack {
18
public:
19
    typedef T                   value_type;
20
    typedef size_t              size_type;
21
    typedef ptrdiff_t           difference_type;
22
    typedef T&                  reference;
23
    typedef const T&            const_reference;
24
    typedef T*                  pointer;
25
    typedef const T*            const_pointer;
26
public:
27
    inline                      stack (void)                    : m_Storage () { }
28
    explicit inline             stack (const vector<T>& s)      : m_Storage (s) { }
29
    explicit inline             stack (const stack& s)          : m_Storage (s.m_Storage) { }
30
    inline bool                 empty (void) const              { return (m_Storage.empty()); }
31
    inline size_type            size (void) const               { return (m_Storage.size()); }
32
    inline reference            top (void)                      { return (m_Storage.back()); }
33
    inline const_reference      top (void) const                { return (m_Storage.back()); }
34
    inline void                 push (const value_type& v)      { m_Storage.push_back (v); }
35
    inline void                 pop (void)                      { m_Storage.pop_back(); }
36
    inline bool                 operator== (const stack& s) const       { return (m_Storage == s.m_Storage); }
37
    inline bool                 operator< (const stack& s) const        { return (m_Storage.size() < s.m_Storage.size()); }
38
private:
39
    vector<T>                   m_Storage;      ///< Where the data actually is.
40
};
41
 
42
} // namespace ustl
43
 
44
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.