Skip to content

Commit

Permalink
Demo test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAihopGG committed Jul 1, 2024
1 parent 6e2634b commit aa3d9d9
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions examples/uqueue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# UQueue
## Introduction

UQueue is class which is simplifying working with queue.
It has many methods, properties, magic methods.

Firstly, import `UQueue` from `ufpy`
```python
from ufpy import UQueue
```

## Create UQueue

For creating UQueue you should use this code:
```python
q = UQueue(1, 2, 3, 4, 5)
```

## Get head

To get head of the queue use:
```python
q.head # 5
```

## Add value

To add value you can use
```python
q.push(6) # [1, 2, 3, 4, 5, 6]
```

## Set head

To set end you can use
```python
q.set_head(7) # [1, 2, 3, 4, 5, 7]
```

## Delete value

For deleting the first element use
```python
q.pop() # [2, 3, 4, 5, 7]
```

## Get length of queue

You can get the length of the queue using the built-in len() function.

```python
q2 = UQueue(1, 2, 3, 4, 5)
len(q2) # 5
```

## Reserve
To reserve the queue's end and beginning, use the built-in `reserved()` function
```python
reserved(q2) # [5, 4, 3, 2, 1]
```

## Iteration
`UQueue()` suppots iteration:
```python
for var in q2:
print(var)
# 1
# 2
# 3
# 4
# 5
```

> [!NOTE]
> After using `for` your queue will be empty:
> ```python
> print(q2) # []
> ```

0 comments on commit aa3d9d9

Please sign in to comment.