queue

概要:キューアダプター
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
template<
    class TType,
    class TContainer // = std::deque<TType>
>
class queue
{
public:
    typedef typename TContainer::value_type value_type;
//  typedef typename TContainer::reference reference;
//  typedef typename TContainer::const_reference const_reference;
    typedef typename TContainer::size_type size_type;
    typedef TContainer container_type;
    explicit queue(const TContainer& C_ = TContainer()) : container_(C_) {}
    bool empty() const { return (container_.empty()); }
    size_type size() const { return (container_.size()); }
    value_type& front() { return (container_.front()); }
    const value_type& front() const { return (container_.front()); }
    value_type& back() { return (container_.back()); }
    const value_type& back() const { return (container_.back()); }
    void push(const value_type& value) { container_.push_back(value); }
//  void push(value_type&& value) { container_.push_back(std::move(value)); }
//  template <class... Args> void emplace(Args&&... args) { container_.emplace_back(std::forward<Args>(args)...); }
    void pop() { container_.pop_front(); }
//  void swap(queue& rhs) noexcept(noexcept(swap(container_, rhs.container_))) { std::swap(container_, rhs.container_); }
    bool operator==(const queue<TType, TContainer>& rhs) const { return (container_ == rhs.container_); }
    bool operator!=(const queue<TType, TContainer>& rhs) const { return (!(*this == rhs)); }
    bool operator< (const queue<TType, TContainer>& rhs) const { return (container_ < rhs.container_); }
    bool operator> (const queue<TType, TContainer>& rhs) const { return (rhs < *this); }
    bool operator<=(const queue<TType, TContainer>& rhs) const { return (!(rhs < *this)); }
    bool operator>=(const queue<TType, TContainer>& rhs) const { return (!(*this < rhs)); }
protected:
    TContainer container_;
};