1 /********************* */
2 /*! \file cdtrail_queue.h
4 ** Top contributors (to current version):
5 ** Tim King, Mathias Preiner
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8 ** in the top-level source directory and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
12 ** \brief Context-dependent queue class with an explicit trail of elements
14 ** Context-dependent First-In-First-Out queue class.
15 ** The implementation is based on a combination of CDList and a CDO<size_t>
16 ** for tracking the next element to dequeue from the list.
17 ** The implementation is currently not full featured.
20 #include "cvc4_private.h"
22 #ifndef CVC4__CONTEXT__CDTRAIL_QUEUE_H
23 #define CVC4__CONTEXT__CDTRAIL_QUEUE_H
25 #include "context/context.h"
26 #include "context/cdlist.h"
36 /** List of elements in the queue. */
39 /** Points to the next element in the current context to dequeue. */
45 /** Creates a new CDTrailQueue associated with the current context. */
46 CDTrailQueue(Context
* context
)
51 /** Returns true if the queue is empty in the current context. */
53 return d_iter
>= d_list
.size();
57 * Enqueues an element in the current context.
58 * Returns its index in the queue.
60 size_t enqueue(const T
& data
){
61 size_t res
= d_list
.size();
62 d_list
.push_back(data
);
66 size_t frontIndex() const{
70 const T
& front() const{
71 return d_list
[frontIndex()];
74 /** Moves the iterator for the queue forward. */
76 Assert(!empty()) << "Attempting to queue from an empty queue.";
80 const T
& operator[](size_t index
) const{
81 Assert(index
< d_list
.size());
89 };/* class CDTrailQueue<> */
91 }/* CVC4::context namespace */
94 #endif /* CVC4__CONTEXT__CDTRAIL_QUEUE_H */