> For the complete documentation index, see [llms.txt](https://docs.yavuzlar.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yavuzlar.org/egitim/c-plus-plus/4.0-veri-yapilari-data-structures/4.6-deque-cift-uclu-kuyruk.md).

# 4.6 Deque (Çift Uçlu Kuyruk)

C++ dilinde deque (double-ended queue), hem başından hem de sonundan eleman ekleyip çıkarabileceğiniz bir veri yapısıdır. Deque'ler, hem FIFO (First In, First Out - İlk Giren İlk Çıkar) hem de LIFO (Last In, First Out - Son Giren İlk Çıkar) mantığına göre çalışabilir. Bu özellikleri sayesinde, çeşitli uygulamalarda esneklik sağlar.

#### Deque'in Temel Özellikleri

1. **Çift Uçlu Yapı**: Elemanlar, hem ön (front) hem de arka (back) uçlardan eklenip çıkarılabilir.
2. **Dinamik Boyutlandırma**: Deque, dinamik olarak boyutlandırılabilir. Yani, eleman ekledikçe boyutu otomatik olarak büyür.
3. **Rastgele Erişim**: Deque, elemanlara rastgele erişim sağlar, bu da belirli bir indeksteki elemana doğrudan erişim imkanı sunar.

#### Deque Kullanımı

C++'ta deque kullanmak için `#include <deque>` kütüphanesini dahil etmeniz gerekmektedir. Aşağıda deque'in temel kullanımına dair örnekler bulunmaktadır.

**Deque Oluşturma ve Eleman Ekleme**

```cpp
#include <iostream>
#include <deque>

int main() {
    // Deque oluşturma
    std::deque<int> deq;

    // Eleman ekleme
    deq.push_back(10); // Arka uca ekleme
    deq.push_front(20); // Ön uca ekleme
    deq.push_back(30);

    // Deque elemanlarını yazdırma
    std::cout << "Deque elemanları: ";
    for (const int& elem : deq) {
        std::cout << elem << " ";
    }
    std::cout << std::endl;

    return 0;
}
```

**Eleman Çıkarma**

Deque'den eleman çıkarmak için `pop_back()` ve `pop_front()` fonksiyonları kullanılır.

```cpp
#include <iostream>
#include <deque>

int main() {
    // Deque oluşturma
    std::deque<int> deq;
    deq.push_back(10);
    deq.push_back(20);
    deq.push_back(30);

    // Deque'den eleman çıkarma
    std::cout << "Deque'den çıkarılan ön eleman: " << deq.front() << std::endl;
    deq.pop_front(); // Ön uçtan çıkar

    std::cout << "Deque'den çıkarılan arka eleman: " << deq.back() << std::endl;
    deq.pop_back(); // Arka uçtan çıkar

    std::cout << "Kalan elemanlar: ";
    for (const int& elem : deq) {
        std::cout << elem << " ";
    }
    std::cout << std::endl;

    return 0;
}
```

**Rastgele Erişim**

Deque'deki elemanlara indeks numarasıyla erişim mümkündür.

```cpp
#include <iostream>
#include <deque>

int main() {
    // Deque oluşturma
    std::deque<int> deq = {10, 20, 30, 40};

    // Rastgele erişim
    std::cout << "2. indeksdeki eleman: " << deq[2] << std::endl; // 30

    return 0;
}
```

#### Sonuç

C++ Deque, esnekliği sayesinde birçok uygulama için yararlı bir veri yapısıdır. Hem ön hem de arka uçlardan eleman ekleyip çıkarabilme özelliği, onu özellikle dinamik veri yapıları için uygun hale getirir.


---

# 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://docs.yavuzlar.org/egitim/c-plus-plus/4.0-veri-yapilari-data-structures/4.6-deque-cift-uclu-kuyruk.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.
