Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:

jobs:
build:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
smalltalk: [Pharo64-14, Pharo64-13, Pharo64-12, Pharo64-11, Pharo64-10]

runs-on: ${{ matrix.os }}
name: ${{ matrix.smalltalk }} on ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Setup SmalltalkCI
uses: hpi-swa/setup-smalltalkCI@v1
with:
smalltalk-version: ${{ matrix.smalltalk }}
- name: Load and Test
run: smalltalkci -s ${{ matrix.smalltalk }}
shell: bash
timeout-minutes: 15
31 changes: 0 additions & 31 deletions .github/workflows/matrix.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

75 changes: 45 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,64 @@
# Containers-Queue
A High-performance, Circular Array based Queue implementation providing efficient FIFO (First In, First Out) operations with dynamic capacity and proper error handling.

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

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

This package is part of the Containers project: This project is to collect, clean,
test and document alternate collection datastructures. Each package is modular so that users
can only load the collection they need without 100 of related collections.
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.

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

```smalltalk
CTEnvironmentTest >> testDequeue [

| queue |
queue := CTQueue new.
queue queue: 1.
queue queue: 2.
queue queue: 3.
self assert: queue dequeue equals: 1.
self assert: queue dequeue equals: 2.
]
```

## Loading
## Loading
The following script installs Containers-Queue in Pharo.

```smalltalk
Metacello new
baseline: 'ContainersQueue';
repository: 'github://pharo-containers/Containers-Queue/';
load.
baseline: 'ContainersQueue';
repository: 'github://pharo-containers/Containers-Queue/src';
load.
```

## If you want to depend on it
## If you want to depend on it

Add the following code to your Metacello baseline or configuration

```smalltalk
spec
baseline: 'ContainersQueue'
with: [ spec repository: 'github://pharo-containers/Containers-Queue/src' ].
```

## Quick Start

```smalltalk
"Create a queue with default capacity of 10"
queue := CTQueue new.

"Enqueue elements"
queue enqueue: 'first'.
queue enqueue: 'second'.
queue enqueue: 'third'.

"Check front element without removing"
queue front. "Returns 'first'"
queue size. "Returns 3"

"Dequeue elements (FIFO order)"
queue dequeue. "Returns 'first'"
queue dequeue. "Returns 'second'"
queue dequeue. "Returns 'third'"

"Queue is now empty"
queue isEmpty. "Returns true"
```

## Contributing

----
The best way to predict the future is to do it!
Less talking more doing. [email protected]
This is part of the Pharo Containers project. Feel free to contribute by implementing additional methods, improving tests, or enhancing documentation.
14 changes: 9 additions & 5 deletions src/BaselineOfContainersQueue/BaselineOfContainersQueue.class.st
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
"
I represent the baseline for Queue DS Implementation
"
Class {
#name : #BaselineOfContainersQueue,
#superclass : #BaselineOf,
#category : #BaselineOfContainersQueue
#name : 'BaselineOfContainersQueue',
#superclass : 'BaselineOf',
#category : 'BaselineOfContainersQueue',
#package : 'BaselineOfContainersQueue'
}

{ #category : #baselines }
{ #category : 'baselines' }
BaselineOfContainersQueue >> baseline: spec [
<baseline>

spec for: #pharo do: [
spec package: 'Containers-Queue'.
spec package: 'Containers-Queue-Tests' with: [ spec requires: #('Containers-Queue')]
spec package: 'Containers-Queue-Tests' with: [ spec requires: #('Containers-Queue') ]
]
]
2 changes: 1 addition & 1 deletion src/BaselineOfContainersQueue/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #BaselineOfContainersQueue }
Package { #name : 'BaselineOfContainersQueue' }
Loading
Loading