# FixedQueue

std::queueは、ブロック単位でのメモリ確保を行い動的にキューのサイズを拡張していきますが、本クラスではメモリサイズを抑制し固定長のキューを実装します。

```cpp
template<typename T>
class FixedQueue : public std::queue<T> { ... };
```

本クラスは`std::queue`を継承しています。

## バッファのブロックサイズ

GCCの場合はバッファのブロックサイズを定義することができます。

本ライブラリでの利用を想定し以下のように64バイトにしています。

```cpp
#if __GNUC__
#define _GLIBCXX_DEQUE_BUF_SIZE 64
     // smaller chunk for deque in GCC, the dafalt size
     // 512bytes are too big for embedded systems.
#endif

#include <deque>
#include <queue>
```

## メソッド

### FixedQueue() - コンストラクタ

```cpp
FixedQueue(std::size_t size)
```

`size`を最大値としてキューを生成します。

### push()

```cpp
bool push(T value)
```

キューに要素を追加します。キューが一杯になると何もせず`false`を返します。

### pop()

```cpp
void pop()
```

キューから要素を削除します。

### front()

```cpp
T& std::queue<T>::front()
```

要素にアクセスします。

### empty()

```cpp
bool std::queue<T>::empty()
```

キューが空の場合`true`を返します。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mwm5.twelite.info/master-2/references/basics/tweutils/fixedqueue.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
