{"id":15037776,"url":"https://github.com/mauriciosantos/buckets-swift","last_synced_at":"2025-04-09T23:32:53.613Z","repository":{"id":28723515,"uuid":"32244645","full_name":"mauriciosantos/Buckets-Swift","owner":"mauriciosantos","description":"Swift Collection Data Structures Library","archived":false,"fork":false,"pushed_at":"2019-01-20T18:05:48.000Z","size":2811,"stargazers_count":118,"open_issues_count":9,"forks_count":14,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-03T20:37:52.628Z","etag":null,"topics":["bimap","bitarray","bloom-filter","carthage","circular-buffer","cocoapods","deque","graph","matrix","multimap","multiset","priority-queue","queue","stack","swift","swift-3","swift-package-manager","trie"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mauriciosantos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-15T04:14:48.000Z","updated_at":"2024-02-20T08:38:08.000Z","dependencies_parsed_at":"2022-09-04T23:12:03.660Z","dependency_job_id":null,"html_url":"https://github.com/mauriciosantos/Buckets-Swift","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauriciosantos%2FBuckets-Swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauriciosantos%2FBuckets-Swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauriciosantos%2FBuckets-Swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauriciosantos%2FBuckets-Swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mauriciosantos","download_url":"https://codeload.github.com/mauriciosantos/Buckets-Swift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248129967,"owners_count":21052670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bimap","bitarray","bloom-filter","carthage","circular-buffer","cocoapods","deque","graph","matrix","multimap","multiset","priority-queue","queue","stack","swift","swift-3","swift-package-manager","trie"],"created_at":"2024-09-24T20:35:39.440Z","updated_at":"2025-04-09T23:32:53.573Z","avatar_url":"https://github.com/mauriciosantos.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Buckets](https://github.com/mauriciosantos/Buckets-Swift/)\n\n[![Build Status](https://travis-ci.org/mauriciosantos/Buckets-Swift.svg?branch=master)](https://travis-ci.org/mauriciosantos/Buckets-Swift)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Buckets.svg)](https://img.shields.io/cocoapods/v/Buckets.svg)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Platform](https://img.shields.io/cocoapods/p/Buckets.svg?style=flat)](http://cocoadocs.org/docsets/Buckets)\n\n**Swift Collections Library**\n\nBuckets is a complete, tested and documented collections library for swift.\n\n## Requirements\n\nSwift 3.0+ platforms such as:\n\nLinux/iOS 9.0+/MacOS 10.10+/watchOS 2.0+/tvOS 9.0+\n\n## Included collections\n\n- [Queue](http://mauriciosantos.github.io/Buckets-Swift/Structs/Queue.html)\n- [Deque](http://mauriciosantos.github.io/Buckets-Swift/Structs/Deque.html)\n- [Stack](http://mauriciosantos.github.io/Buckets-Swift/Structs/Stack.html)\n- [PriorityQueue](http://mauriciosantos.github.io/Buckets-Swift/Structs/PriorityQueue.html)\n- [Multiset](http://mauriciosantos.github.io/Buckets-Swift/Structs/Multiset.html)\n- [Multimap](http://mauriciosantos.github.io/Buckets-Swift/Structs/Multimap.html)\n- [Bimap](http://mauriciosantos.github.io/Buckets-Swift/Structs/Bimap.html)\n- [Graph](http://mauriciosantos.github.io/Buckets-Swift/Structs/Graph.html)\n- [Trie](http://mauriciosantos.github.io/Buckets-Swift/Structs/Trie.html)\n- [Matrix](http://mauriciosantos.github.io/Buckets-Swift/Structs/Matrix.html)\n- [BitArray](http://mauriciosantos.github.io/Buckets-Swift/Structs/BitArray.html)\n- [CircularArray](http://mauriciosantos.github.io/Buckets-Swift/Structs/CircularArray.html)\n- [BloomFilter](http://mauriciosantos.github.io/Buckets-Swift/Structs/BloomFilter.html)\n\n## Setup\n\n### CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Swift and Objective-C projects. The latest version adds support for embedded frameworks. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\nTo integrate Buckets into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '10.0'\nuse_frameworks!\n\ntarget 'TargetName' do\n  pod 'Buckets', '~\u003e 2.0'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage#-carthage) is a decentralized dependency manager that automates the process of adding frameworks to your application.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate Buckets into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"mauriciosantos/Buckets-Swift\" ~\u003e 2.0\n```\n\n### Swift Package Manager\n\nSee [Swift Package Manager documentation](https://swift.org/package-manager/#conceptual-overview)\n\n### Manually\n\nYou can also integrate Buckets into your Xcode project manually:\n\n- Download the [latest release](https://github.com/mauriciosantos/Buckets-Swift/releases) and unzip it in your project's folder.\n- Open the `Buckets` folder, and drag `Buckets.xcodeproj` into the file navigator of your app project. This means inside your project, not at the top level.\n- Ensure that the deployment target of Buckets.framework matches that of the application target.\n- Open your project's \"Build Phases\" panel. Expand the \"Target Dependencies\" group, and add `Buckets.framework`.\n- Click on the `+` button at the top left of the panel and select \"New Copy Files Phase\". Set the \"Destination\" to \"Frameworks\", and add `Buckets.framework`. There are 4 versions for each platform. Select the right one.\n\n## Usage\n\nAll collection types are implemented as structures. This means they are copied when they are assigned to a new constant or variable, or when they are passed to a function or method.\n\nYou shouldn't worry about copying structs:  \n\n\u003e The behavior you see in your code will always be as if a copy took place. However, Swift only performs an actual copy behind the scenes when it is absolutely necessary to do so. Swift manages all value copying to ensure optimal performance, and you should not avoid assignment to try to preempt this optimization.\n\nBuckets collection types are optimized in the same way.\n\n### Walkthrough\n\n```swift\nimport Buckets\n\nvar queue = Queue\u003cString\u003e()\nqueue.enqueue(\"first\")\nqueue.enqueue(\"last\")\nqueue.dequeue() // \"first\"\n\nvar deque = Deque\u003cString\u003e()\ndeque.enqueueLast(\"last\")\ndeque.enqueueFirst(\"first\")\ndeque.dequeueFirst() // \"first\"\n\nvar stack = Stack\u003cString\u003e()\nstack.push(\"first\")\nstack.push(\"last\")\nstack.pop() // \"last\"\n\nvar pQueue = PriorityQueue\u003cInt\u003e(sortedBy: \u003c)\npQueue.enqueue(3)\npQueue.enqueue(1)\npQueue.enqueue(2)\npQueue.dequeue() // 1\n\nvar multiset = Multiset\u003cString\u003e()\nmultiset.insert(\"a\")\nmultiset.insert(\"b\")\nmultiset.insert(\"a\")\nmultiset.distinctCount // 2\nmultiset.count(\"a\") // 2\n\nvar multimap = Multimap\u003cString, Int\u003e()\nmultimap.insertValue(1, forKey: \"a\")\nmultimap.insertValue(5, forKey: \"a\")\nmultimap[\"a\"] // [1, 5]\n\nvar bimap = Bimap\u003cString, Int\u003e()\nbimap[key: \"a\"] = 1\nbimap[value: 3] = \"b\"\nbimap[value: 1] // \"a\"\nbimap[key: \"b\"] // 3\n\nvar graph = Graph\u003cString, Int\u003e()\ngraph[\"Boston\", \"NY\"] = 5\ngraph[\"NY\", \"Miami\"] = 5\ngraph.pathFrom(\"Boston\", to: \"Miami\") // [\"Boston\", \"NY\", \"Miami\"]\n\nvar matrix: Matrix\u003cDouble\u003e = [[1,2,3], [4,5,6]]\nmatrix[1, 0] = 5\nmatrix - [[1,0,1], [1,0,1]] // [[0,2,2],[4,5,5]]\n\nvar bitArray: BitArray = [true, false]\nbitArray.append(true)\nbitArray.cardinality // 2\n\nvar circArray = CircularArray\u003cInt\u003e()\ncircArray.append(1)\ncircArray.prepend(2)\ncircArray.first // 2\n\nvar bFilter = BloomFilter\u003cString\u003e(expectedCount: 100)\nbFilter.insert(\"a\")\nbFilter.contains(\"a\") // true\n```\n\nRead the [documentation](http://mauriciosantos.github.io/Buckets-Swift/Data%20Structures.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauriciosantos%2Fbuckets-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmauriciosantos%2Fbuckets-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauriciosantos%2Fbuckets-swift/lists"}