1 // Copyright 2016 The Draco Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // File defining a coherent interface for different queuing strategies.
16 
17 #ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_QUEUING_POLICY_H_
18 #define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_QUEUING_POLICY_H_
19 
20 #include <queue>
21 #include <stack>
22 #include <utility>
23 
24 namespace draco {
25 
26 template <class T>
27 class Queue {
28  public:
empty()29   bool empty() const { return q_.empty(); }
size()30   typename std::queue<T>::size_type size() const { return q_.size(); }
clear()31   void clear() { return q_.clear(); }
push(const T & value)32   void push(const T &value) { q_.push(value); }
push(T && value)33   void push(T &&value) { q_.push(std::move(value)); }
pop()34   void pop() { q_.pop(); }
front()35   typename std::queue<T>::const_reference front() const { return q_.front(); }
36 
37  private:
38   std::queue<T> q_;
39 };
40 
41 template <class T>
42 class Stack {
43  public:
empty()44   bool empty() const { return s_.empty(); }
size()45   typename std::stack<T>::size_type size() const { return s_.size(); }
clear()46   void clear() { return s_.clear(); }
push(const T & value)47   void push(const T &value) { s_.push(value); }
push(T && value)48   void push(T &&value) { s_.push(std::move(value)); }
pop()49   void pop() { s_.pop(); }
front()50   typename std::stack<T>::const_reference front() const { return s_.top(); }
51 
52  private:
53   std::stack<T> s_;
54 };
55 
56 template <class T, class Compare = std::less<T> >
57 class PriorityQueue {
58   typedef std::priority_queue<T, std::vector<T>, Compare> QType;
59 
60  public:
empty()61   bool empty() const { return s_.empty(); }
size()62   typename QType::size_type size() const { return s_.size(); }
clear()63   void clear() { return s_.clear(); }
push(const T & value)64   void push(const T &value) { s_.push(value); }
push(T && value)65   void push(T &&value) { s_.push(std::move(value)); }
pop()66   void pop() { s_.pop(); }
front()67   typename QType::const_reference front() const { return s_.top(); }
68 
69  private:
70   QType s_;
71 };
72 
73 }  // namespace draco
74 
75 #endif  // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_QUEUING_POLICY_H_
76