> For the complete documentation index, see [llms.txt](https://mwm5.twelite.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mwm5.twelite.info/master-2/references/basics/tweutils/fixedqueue.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
