---
# System prepended metadata

title: 11935 - double-end-queue
tags: [class]

---

# 11935 - double-end-queue
###### tags: `class`
---

## Brief
See the code below

## Solution 0

```cpp=
#include <bits/stdc++.h>
#include "function.h"

// dummy head, dummy tail

void _stack::push(const _node N) {
    _node* new_node = new _node(N.data);
    this->End->prev->next = new_node;
    new_node->prev = this->End->prev;
    new_node->next = this->End;
    this->End->prev = new_node;
}

void _stack::pop() {
    if (this->Begin->next == this->End) return;
    _node* trash = this->End->prev;
    this->End->prev->prev->next = this->End;
    this->End->prev = this->End->prev->prev;
    delete trash;
}

_node* _stack::get_data() {
    if (this->End->prev == this->Begin) return NULL;
    return this->End->prev;
}

void _queue::push(const _node N) {
    _node* new_node = new _node(N.data);
    new_node->next = this->Begin->next;
    this->Begin->next->prev = new_node;
    this->Begin->next = new_node;
    new_node->prev = this->Begin;
}

void _queue::pop() {
    if (this->Begin->next == this->End) return;
    _node* trash = this->End->prev;
    this->End->prev->prev->next = this->End;
    this->End->prev = this->End->prev->prev;
    delete trash;
}

_node* _queue::get_data() {
    if (this->End->prev == this->Begin) return NULL;
    return this->End->prev;
}

// Utin
```

## Reference