aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/small_containers/compact_queue.h
blob: 1852d2970655fdb5557a8c00a24bc6e2362325bc (plain) (blame)
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
34
35
36
37
#pragma once

#include "compact_vector.h"

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

//! A queue optimized for storing elements inline
//! and with little memory overhead. See TCompactVector.
template <class T, size_t N>
class TCompactQueue
{
public:
    void Push(T value);
    T Pop();

    const T& Front() const;

    size_t Size() const;
    size_t Capacity() const;

    bool Empty() const;

private:
    TCompactVector<T, N> Queue_ = TCompactVector<T, N>(N);
    size_t FrontIndex_ = 0;
    size_t Size_ = 0;
};

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT

#define COMPACT_QUEUE_INL_H_
#include "compact_queue-inl.h"
#undef COMPACT_QUEUE_INL_H_