Skip to content

Commit 096cf73

Browse files
authored
Merge pull request #15 from Alokzh/fix/queue-implementation-improvements
Improve Queue DS Implementation, Tests, Workflows & Readme
2 parents 11667b6 + 07cfc67 commit 096cf73

11 files changed

Lines changed: 653 additions & 395 deletions

File tree

.github/workflows/CI.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
env:
4+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5+
6+
on:
7+
push:
8+
branches: [master]
9+
pull_request:
10+
branches: [master]
11+
workflow_dispatch:
12+
13+
jobs:
14+
build:
15+
strategy:
16+
matrix:
17+
os: [macos-latest, ubuntu-latest, windows-latest]
18+
smalltalk: [Pharo64-14, Pharo64-13, Pharo64-12, Pharo64-11, Pharo64-10]
19+
20+
runs-on: ${{ matrix.os }}
21+
name: ${{ matrix.smalltalk }} on ${{ matrix.os }}
22+
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: Setup SmalltalkCI
26+
uses: hpi-swa/setup-smalltalkCI@v1
27+
with:
28+
smalltalk-version: ${{ matrix.smalltalk }}
29+
- name: Load and Test
30+
run: smalltalkci -s ${{ matrix.smalltalk }}
31+
shell: bash
32+
timeout-minutes: 15

.github/workflows/matrix.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

README.md

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,64 @@
11
# Containers-Queue
2+
A High-performance, Circular Array based Queue implementation providing efficient FIFO (First In, First Out) operations with dynamic capacity and proper error handling.
23

3-
[![Build Status](https://travis-ci.com/pharo-containers/Containers-Queue.svg?branch=master)](https://travis-ci.com/pharo-containers/Containers-Queue)
4-
[![License](https://img.shields.io/badge/license-MIT-blue.svg)]()
5-
[![Pharo version](https://img.shields.io/badge/Pharo-7.0-%23aac9ff.svg)](https://pharo.org/download)
6-
[![Pharo version](https://img.shields.io/badge/Pharo-8.0-%23aac9ff.svg)](https://pharo.org/download)
4+
![Pharo Version](https://img.shields.io/badge/Pharo-10+-blue)
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
76

8-
A queue support FIFO (first in first out) behavior. Now it is a bit limited so feel free to enhance it.
7+
## What is a Queue?
98

10-
This package is part of the Containers project: This project is to collect, clean,
11-
test and document alternate collection datastructures. Each package is modular so that users
12-
can only load the collection they need without 100 of related collections.
9+
A Queue is a linear data structure that follows the FIFO (First In, First Out) principle. Elements are added at the rear (enqueue) and removed from the front (dequeue). Think of it like a line at a store - the first person in line is the first person served.
1310

14-
## Example
11+
### Key Benefits
12+
- **O(1) Performance**: Constant time enqueue, dequeue, and front operations
13+
- **Dynamic Growth**: Circular array implementation that doubles capacity when needed
14+
- **Memory Safe**: Automatic cleanup prevents memory leaks
15+
- **Simple API**: Clean, intuitive interface following standard queue conventions
16+
- **Robust Error Handling**: Proper empty queue protection with clear error messages
1517

16-
```smalltalk
17-
CTEnvironmentTest >> testDequeue [
18-
19-
| queue |
20-
queue := CTQueue new.
21-
queue queue: 1.
22-
queue queue: 2.
23-
queue queue: 3.
24-
self assert: queue dequeue equals: 1.
25-
self assert: queue dequeue equals: 2.
26-
]
27-
```
28-
29-
## Loading
18+
## Loading
19+
The following script installs Containers-Queue in Pharo.
3020

3121
```smalltalk
3222
Metacello new
33-
baseline: 'ContainersQueue';
34-
repository: 'github://pharo-containers/Containers-Queue/';
35-
load.
23+
baseline: 'ContainersQueue';
24+
repository: 'github://pharo-containers/Containers-Queue/src';
25+
load.
3626
```
3727

38-
## If you want to depend on it
28+
## If you want to depend on it
29+
30+
Add the following code to your Metacello baseline or configuration
3931

4032
```smalltalk
4133
spec
4234
baseline: 'ContainersQueue'
4335
with: [ spec repository: 'github://pharo-containers/Containers-Queue/src' ].
4436
```
4537

38+
## Quick Start
39+
40+
```smalltalk
41+
"Create a queue with default capacity of 10"
42+
queue := CTQueue new.
43+
44+
"Enqueue elements"
45+
queue enqueue: 'first'.
46+
queue enqueue: 'second'.
47+
queue enqueue: 'third'.
48+
49+
"Check front element without removing"
50+
queue front. "Returns 'first'"
51+
queue size. "Returns 3"
52+
53+
"Dequeue elements (FIFO order)"
54+
queue dequeue. "Returns 'first'"
55+
queue dequeue. "Returns 'second'"
56+
queue dequeue. "Returns 'third'"
57+
58+
"Queue is now empty"
59+
queue isEmpty. "Returns true"
60+
```
61+
62+
## Contributing
4663

47-
----
48-
The best way to predict the future is to do it!
49-
Less talking more doing. stephane.ducasse@inria.fr
64+
This is part of the Pharo Containers project. Feel free to contribute by implementing additional methods, improving tests, or enhancing documentation.
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
"
2+
I represent the baseline for Queue DS Implementation
3+
"
14
Class {
2-
#name : #BaselineOfContainersQueue,
3-
#superclass : #BaselineOf,
4-
#category : #BaselineOfContainersQueue
5+
#name : 'BaselineOfContainersQueue',
6+
#superclass : 'BaselineOf',
7+
#category : 'BaselineOfContainersQueue',
8+
#package : 'BaselineOfContainersQueue'
59
}
610

7-
{ #category : #baselines }
11+
{ #category : 'baselines' }
812
BaselineOfContainersQueue >> baseline: spec [
913
<baseline>
1014

1115
spec for: #pharo do: [
1216
spec package: 'Containers-Queue'.
13-
spec package: 'Containers-Queue-Tests' with: [ spec requires: #('Containers-Queue')]
17+
spec package: 'Containers-Queue-Tests' with: [ spec requires: #('Containers-Queue') ]
1418
]
1519
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Package { #name : #BaselineOfContainersQueue }
1+
Package { #name : 'BaselineOfContainersQueue' }

0 commit comments

Comments
 (0)