From 7820bb9baf10b83bf761394adf417918a3e4ccb0 Mon Sep 17 00:00:00 2001 From: Alokzh Date: Thu, 10 Jul 2025 08:06:25 +0530 Subject: [PATCH] Improve CI config & enhance Readme --- .github/workflows/CI.yml | 32 ++++++++++++ .github/workflows/matrix.yml | 31 ------------ .travis.yml | 40 --------------- README.md | 97 +++++++++++++++++++++++++++++------- appveyor.yml | 29 ----------- 5 files changed, 111 insertions(+), 118 deletions(-) create mode 100644 .github/workflows/CI.yml delete mode 100644 .github/workflows/matrix.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..eb20c59 --- /dev/null +++ b/.github/workflows/CI.yml @@ -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-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 \ No newline at end of file diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml deleted file mode 100644 index 4884745..0000000 --- a/.github/workflows/matrix.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: matrix - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - build: - strategy: - matrix: - os: [ macos-latest, ubuntu-latest ] - smalltalk: [ Pharo64-8.0, Pharo64-7.0 ] - runs-on: ${{ matrix.os }} - name: ${{ matrix.smalltalk }} on ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - name: Setup smalltalkCI - uses: hpi-swa/setup-smalltalkCI@v1 - with: - smalltalk-version: ${{ matrix.smalltalk }} - - name: Load Image and Run Tests - run: smalltalkci -s ${{ matrix.smalltalk }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - timeout-minutes: 15 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a32c78c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -language: smalltalk -sudo: false - -# Select operating system(s) -os: - - linux - - osx - -# Select compatible Smalltalk image(s) -smalltalk: -# - Squeak-trunk -# - Squeak-5.1 -# - Squeak-5.0 -# - Squeak-4.6 -# - Squeak-4.5 - -# - Pharo-alpha -# - Pharo-stable - - Pharo32-8.0 - - Pharo-7.0 - - Pharo-6.1 -# - Pharo-5.0 -# - Pharo-4.0 -# - Pharo-3.0 - -# - Pharo64-alpha -# - Pharo64-stable - - Pharo64-9.0 - - Pharo64-8.0 - - Pharo64-7.0 - - Pharo64-6.1 - -# - GemStone-3.3.0 -# - GemStone-3.2.12 -# - GemStone-3.1.0.6 - -# Uncomment to enable caching (only useful for GemStone builds (3x faster)) -#cache: -# directories: -# - $SMALLTALK_CI_CACHE diff --git a/README.md b/README.md index 751086f..59ddd44 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,19 @@ # Containers-OrderedSet -[![Build Status](https://travis-ci.org/olekscode/Containers-OrderedSet.svg?branch=master)](https://travis-ci.org/olekscode/Containers-OrderedSet) -[![Build status](https://ci.appveyor.com/api/projects/status/te7uf184lua3svb4?svg=true)](https://ci.appveyor.com/project/olekscode/containers-orderedset) -[![Coverage Status](https://coveralls.io/repos/github/olekscode/Containers-OrderedSet/badge.svg?branch=master)](https://coveralls.io/github/olekscode/Containers-OrderedSet?branch=master) -[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/olekscode/Containers-OrderedSet/master/LICENSE) -[![Pharo version](https://img.shields.io/badge/Pharo-6.1-%23aac9ff.svg)](https://pharo.org/download) -[![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 `Set` where an order of elements matters or an `OrderedCollection` with no duplicates. Supports the complete API of `Set` and `OrderedCollection`. +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. + +### Key Features +- **Maintains Insertion Order**: Elements are stored in the order they were added. +- **Ensures Uniqueness**: No duplicate elements are allowed. +- **Indexed Access**: Elements can be accessed by their index, similar to an array. +- **Rich API**: Combines methods from both `Set` and `OrderedCollection`, allowing for flexible usage. +- **Developer Productivity**: Simplifies code by eliminating the need for manual duplicate checks and order management. ## Installation -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`): +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`): ```Smalltalk Metacello new @@ -33,18 +35,77 @@ spec 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). ## How to use it? +You can create an `OrderedSet` and use it like this: +```smalltalk +| orderedSet | +orderedSet := CTOrderedSet new. +orderedSet add: 'Apple'. +orderedSet add: 'Banana'. +orderedSet add: 'Apple'. "This will not add a duplicate" +orderedSet add: 'Cherry'. +orderedSet do: [ :each | Transcript show: each; cr ]. +``` +This will output: +``` +Apple +Banana +Cherry +``` -`CTOrderedSet` has the same API as `OrderedCollection`, extended with the methods of `Set`. So instance creation looks the same: +### Real World Use Case: Blog Tag Management +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. -```Smalltalk -firstBasket := CTOrderedSet withAll: #(apple apple orange banana orange banana). -secondBasket := CTOrderedSet withAll: #(banana apple banana banana). -``` +```smalltalk +"Blog post tag management - Maintain order, Ensure uniqueness" -Or you can use the `asOrderedSet` method: +"Traditional approach with OrderedCollection - problematic" +blogTags := OrderedCollection new. +blogTags + add: 'Programming'; + add: 'Pharo'; + add: 'Tutorial'; + add: 'Programming'; "Oops! Duplicate" + add: 'Beginner'; + add: 'Pharo'. "Another duplicate" +"Manual cleanup required - inefficient and error-prone" +blogTags := blogTags asSet asOrderedCollection. "Loses order!" +"Result: Unpredictable order, Manual management needed" -```Smalltalk -firstBasket := #(apple apple orange banana orange banana) asOrderedSet. -secondBasket := #(banana apple banana banana) asOrderedSet. +"OrderedSet approach - Elegant and Automatic" +blogTags := CTOrderedSet new. +blogTags + add: 'Programming'; + add: 'Pharo'; + add: 'Tutorial'; + add: 'Programming'; "Automatically ignored - No duplicate" + add: 'Beginner'; + add: 'Pharo'. "Automatically ignored - No duplicate" + +"Result: #('Programming' 'Pharo' 'Tutorial' 'Beginner') - Perfect order, No duplicates" + +"Adding tags from user input or external sources" +userInputTags := #('Advanced' 'Programming' 'Smalltalk' 'Tutorial'). +blogTags addAll: userInputTags. +"Result: #('Programming' 'Pharo' 'Tutorial' 'Beginner' 'Advanced' 'Smalltalk') - Maintains order, no duplicates" +"Notice: Duplicates automatically filtered, new tags appended in order" + +blogTags includes: 'Pharo'. "Returns: True" +blogTags includes: 'JavaScript'. "Returns: False" + +firstTag := blogTags first. "Access first tag - 'Programming'" +lastTag := blogTags last. "Access last tag - 'Smalltalk'" +thirdTag := blogTags at: 3. "Access third tag - 'Tutorial'" ``` +### Comparison with Alternatives + +| Feature | OrderedCollection | Set | CTOrderedSet | +|---------|------------------|-----|-------------| +| Maintains order | Yes | No | Yes | +| Prevents duplicates | No | Yes | Yes | +| Indexed access | Yes | No | Yes | +| Manual Duplicate Check | Required | Not Required | Not Required | + +## Contributing + +This is part of the Pharo Containers project. Feel free to contribute by implementing additional methods, improving tests, or enhancing documentation. \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5a98a4d..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,29 +0,0 @@ -environment: - CYG_ROOT: C:\cygwin - CYG_BASH: C:\cygwin\bin\bash - CYG_CACHE: C:\cygwin\var\cache\setup - CYG_EXE: C:\cygwin\setup-x86.exe - CYG_MIRROR: http://cygwin.mirror.constant.com - SCI_RUN: /cygdrive/c/smalltalkCI-master/run.sh - matrix: - # Currently, only Squeak and Pharo images are supported on AppVeyor. -# - SMALLTALK: Squeak-trunk -# - SMALLTALK: Squeak-5.0 - - SMALLTALK: Pharo64-8.0 - - SMALLTALK: Pharo-7.0 - - SMALLTALK: Pharo-6.1 -# - SMALLTALK: Pharo-5.0 - # ... - -platform: - - x86 - -install: - - '%CYG_EXE% -dgnqNO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P unzip' - - ps: Start-FileDownload "https://github.com/hpi-swa/smalltalkCI/archive/master.zip" "C:\smalltalkCI.zip" - - 7z x C:\smalltalkCI.zip -oC:\ -y > NULL - -build: false - -test_script: - - '%CYG_BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0