Skip to content

Commit 92f984e

Browse files
authored
Merge pull request #6 from Alokzh/improve-ci-workflow-and-readme
Improve CI configuration & enhance Readme File
2 parents 21057ee + 7820bb9 commit 92f984e

File tree

5 files changed

+111
-118
lines changed

5 files changed

+111
-118
lines changed

.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-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 & 40 deletions
This file was deleted.

README.md

Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Containers-OrderedSet
22

3-
[![Build Status](https://travis-ci.org/olekscode/Containers-OrderedSet.svg?branch=master)](https://travis-ci.org/olekscode/Containers-OrderedSet)
4-
[![Build status](https://ci.appveyor.com/api/projects/status/te7uf184lua3svb4?svg=true)](https://ci.appveyor.com/project/olekscode/containers-orderedset)
5-
[![Coverage Status](https://coveralls.io/repos/github/olekscode/Containers-OrderedSet/badge.svg?branch=master)](https://coveralls.io/github/olekscode/Containers-OrderedSet?branch=master)
6-
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/olekscode/Containers-OrderedSet/master/LICENSE)
7-
[![Pharo version](https://img.shields.io/badge/Pharo-6.1-%23aac9ff.svg)](https://pharo.org/download)
8-
[![Pharo version](https://img.shields.io/badge/Pharo-7.0-%23aac9ff.svg)](https://pharo.org/download)
9-
[![Pharo version](https://img.shields.io/badge/Pharo-8.0-%23aac9ff.svg)](https://pharo.org/download)
3+
![Pharo Version](https://img.shields.io/badge/Pharo-10+-blue)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
105

11-
A `Set` where an order of elements matters or an `OrderedCollection` with no duplicates. Supports the complete API of `Set` and `OrderedCollection`.
6+
A `CTOrderedSet` is a collection that combines the properties of a `Set` and an `OrderedCollection`. It maintains the order of elements while ensuring that there are no duplicates, similar to a `Set`. This makes it a useful data structure when you need to keep track of the order in which items were added, while also enforcing uniqueness.
7+
8+
### Key Features
9+
- **Maintains Insertion Order**: Elements are stored in the order they were added.
10+
- **Ensures Uniqueness**: No duplicate elements are allowed.
11+
- **Indexed Access**: Elements can be accessed by their index, similar to an array.
12+
- **Rich API**: Combines methods from both `Set` and `OrderedCollection`, allowing for flexible usage.
13+
- **Developer Productivity**: Simplifies code by eliminating the need for manual duplicate checks and order management.
1214

1315
## Installation
14-
To install `CTOrderedSet`, go to the Playground (`Ctrl+OW`) in your [Pharo](https://pharo.org/) image and execute the following Metacello script (select it and press Do-it button or `Ctrl+D`):
16+
To install `CTOrderedSet`, go to the Playground in your [Pharo](https://pharo.org/) image and execute the following Metacello script (select it and press Do-it button or `Ctrl+D`):
1517

1618
```Smalltalk
1719
Metacello new
@@ -33,18 +35,77 @@ spec
3335
To read more about baselines and Metacello, check out the [Baselines](https://github.com/pharo-open-documentation/pharo-wiki/blob/master/General/Baselines.md) article on [Pharo Wiki](https://github.com/pharo-open-documentation/pharo-wiki).
3436

3537
## How to use it?
38+
You can create an `OrderedSet` and use it like this:
39+
```smalltalk
40+
| orderedSet |
41+
orderedSet := CTOrderedSet new.
42+
orderedSet add: 'Apple'.
43+
orderedSet add: 'Banana'.
44+
orderedSet add: 'Apple'. "This will not add a duplicate"
45+
orderedSet add: 'Cherry'.
46+
orderedSet do: [ :each | Transcript show: each; cr ].
47+
```
48+
This will output:
49+
```
50+
Apple
51+
Banana
52+
Cherry
53+
```
3654

37-
`CTOrderedSet` has the same API as `OrderedCollection`, extended with the methods of `Set`. So instance creation looks the same:
55+
### Real World Use Case: Blog Tag Management
56+
Let's explore a comprehensive example that demonstrates the power of `OrderedSet` in a real-world scenario - managing tags for a blog post. This example illustrates how to maintain order, ensure uniqueness, and perform efficient operations on tags.
3857

39-
```Smalltalk
40-
firstBasket := CTOrderedSet withAll: #(apple apple orange banana orange banana).
41-
secondBasket := CTOrderedSet withAll: #(banana apple banana banana).
42-
```
58+
```smalltalk
59+
"Blog post tag management - Maintain order, Ensure uniqueness"
4360
44-
Or you can use the `asOrderedSet` method:
61+
"Traditional approach with OrderedCollection - problematic"
62+
blogTags := OrderedCollection new.
63+
blogTags
64+
add: 'Programming';
65+
add: 'Pharo';
66+
add: 'Tutorial';
67+
add: 'Programming'; "Oops! Duplicate"
68+
add: 'Beginner';
69+
add: 'Pharo'. "Another duplicate"
70+
"Manual cleanup required - inefficient and error-prone"
71+
blogTags := blogTags asSet asOrderedCollection. "Loses order!"
72+
"Result: Unpredictable order, Manual management needed"
4573
46-
```Smalltalk
47-
firstBasket := #(apple apple orange banana orange banana) asOrderedSet.
48-
secondBasket := #(banana apple banana banana) asOrderedSet.
74+
"OrderedSet approach - Elegant and Automatic"
75+
blogTags := CTOrderedSet new.
76+
blogTags
77+
add: 'Programming';
78+
add: 'Pharo';
79+
add: 'Tutorial';
80+
add: 'Programming'; "Automatically ignored - No duplicate"
81+
add: 'Beginner';
82+
add: 'Pharo'. "Automatically ignored - No duplicate"
83+
84+
"Result: #('Programming' 'Pharo' 'Tutorial' 'Beginner') - Perfect order, No duplicates"
85+
86+
"Adding tags from user input or external sources"
87+
userInputTags := #('Advanced' 'Programming' 'Smalltalk' 'Tutorial').
88+
blogTags addAll: userInputTags.
89+
"Result: #('Programming' 'Pharo' 'Tutorial' 'Beginner' 'Advanced' 'Smalltalk') - Maintains order, no duplicates"
90+
"Notice: Duplicates automatically filtered, new tags appended in order"
91+
92+
blogTags includes: 'Pharo'. "Returns: True"
93+
blogTags includes: 'JavaScript'. "Returns: False"
94+
95+
firstTag := blogTags first. "Access first tag - 'Programming'"
96+
lastTag := blogTags last. "Access last tag - 'Smalltalk'"
97+
thirdTag := blogTags at: 3. "Access third tag - 'Tutorial'"
4998
```
5099

100+
### Comparison with Alternatives
101+
102+
| Feature | OrderedCollection | Set | CTOrderedSet |
103+
|---------|------------------|-----|-------------|
104+
| Maintains order | Yes | No | Yes |
105+
| Prevents duplicates | No | Yes | Yes |
106+
| Indexed access | Yes | No | Yes |
107+
| Manual Duplicate Check | Required | Not Required | Not Required |
108+
109+
## Contributing
110+
111+
This is part of the Pharo Containers project. Feel free to contribute by implementing additional methods, improving tests, or enhancing documentation.

appveyor.yml

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

0 commit comments

Comments
 (0)