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/cdlist.h"
26 #include "context/cdo.h"
37 /** List of elements in the queue. */
40 /** Points to the next element in the current context to dequeue. */
46 /** Creates a new CDTrailQueue associated with the current context. */
47 CDTrailQueue(Context
* context
)
52 /** Returns true if the queue is empty in the current context. */
54 return d_iter
>= d_list
.size();
58 * Enqueues an element in the current context.
59 * Returns its index in the queue.
61 size_t enqueue(const T
& data
){
62 size_t res
= d_list
.size();
63 d_list
.push_back(data
);
67 size_t frontIndex() const{
71 const T
& front() const{
72 return d_list
[frontIndex()];
75 /** Moves the iterator for the queue forward. */
77 Assert(!empty()) << "Attempting to queue from an empty queue.";
81 const T
& operator[](size_t index
) const{
82 Assert(index
< d_list
.size());
90 };/* class CDTrailQueue<> */
92 } // namespace context
95 #endif /* CVC4__CONTEXT__CDTRAIL_QUEUE_H */