{"id":17115762,"url":"https://github.com/pathikrit/arraydeque-talk","last_synced_at":"2025-08-03T22:33:47.915Z","repository":{"id":139970033,"uuid":"136760267","full_name":"pathikrit/arraydeque-talk","owner":"pathikrit","description":null,"archived":false,"fork":false,"pushed_at":"2018-06-16T20:38:09.000Z","size":11561,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T07:20:30.475Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://slides.com/pathikrit/arraydeque#/","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pathikrit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-09T21:45:01.000Z","updated_at":"2018-06-20T16:55:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"624cdddb-ac90-4ad2-843c-e8500cc340f3","html_url":"https://github.com/pathikrit/arraydeque-talk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Farraydeque-talk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Farraydeque-talk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Farraydeque-talk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Farraydeque-talk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pathikrit","download_url":"https://codeload.github.com/pathikrit/arraydeque-talk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245191611,"owners_count":20575248,"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":[],"created_at":"2024-10-14T17:46:26.157Z","updated_at":"2025-03-24T00:49:29.986Z","avatar_url":"https://github.com/pathikrit.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"ArrayDeque\n----------\n\n![Alt Text](ArrayDeque.gif)\n\nTo run the code:\n```shell\nsbt \"~runMain Demo\"\n```\n\n\u003cimg width=\"1412\" alt=\"screenshot 2017-03-24 17 26 19\" src=\"https://cloud.githubusercontent.com/assets/899219/24314281/354a9e9a-10b7-11e7-88fe-b28d32517fba.png\"\u003e\n\nPrior discussion: \nhttps://contributors.scala-lang.org/t/using-circular-buffers-as-mutable-arraybuffer/454\n\nSI-10167: https://issues.scala-lang.org/browse/SI-10167\n\nArrayDeque's (implemented using a growable circular buffers using modular arithmetic for indexing) are strictly better data structures than vanilla ArrayBuffers.\n\nThis improves on `java.util.ArrayDeque` by providing an O(1) `get(idx)` and also providing faster `insertAt(idx)` and `deleteAt(idx)` operations.\n\nThis implementation adds `O(1)` `append`, `prepend`, `removeHead`, `removeTail`, `get`, `update` and `clear` APIs. \n\nWe also provide proof of concept replacement implementations of mutable data structures like stack, queues and buffers with ArrayDeque here.\n\nPreliminary benchmarks prove that this data structure can suitably replace `mutable.ArrayBuffer`\n```\n===============[Insert lots of items]=================\n  ArrayDeque:   956.76 ms\n ArrayBuffer:  2473.36 ms\n===============[Drop some items from an head index]=================\n  ArrayDeque:     1.25 ms\n ArrayBuffer:     7.65 ms\n===============[Drop some items from a tail index]=================\n  ArrayDeque:     0.28 ms\n ArrayBuffer:     2.54 ms\n===============[Append lots of items one by one]=================\n  ArrayDeque:  2222.13 ms\n ArrayBuffer:  3576.63 ms\n===============[Prepend few items one by one]=================\n  ArrayDeque:     1.33 ms\n ArrayBuffer:  8699.13 ms\n===============[Prepend lots of items at once]=================\n  ArrayDeque:   462.76 ms\n ArrayBuffer:  2124.02 ms\n===============[Random indexing]=================\n  ArrayDeque:    84.02 ms\n ArrayBuffer:    81.62 ms\n===============[Insert items near head]=================\n  ArrayDeque:  1429.52 ms\n ArrayBuffer:  2980.46 ms\n===============[Reversal]=================\n  ArrayDeque:   378.69 ms\n ArrayBuffer:   491.46 ms\n===============[Insert items near tail]=================\n  ArrayDeque:  2504.20 ms\n ArrayBuffer:  8588.98 ms\n===============[Sliding]=================\n  ArrayDeque:   157.25 ms\n ArrayBuffer:  1591.47 ms\n===============[toArray]=================\n  ArrayDeque:   181.07 ms\n ArrayBuffer:   194.55 ms\n===============[Clear lots of items]=================\n  ArrayDeque:    48.34 ms\n ArrayBuffer:    28.62 ms\n```\n\nTo run benchmarks:\n```shell\nsbt \"test/runMain scala.collection.mutable.ArrayDequeBenchmark\"\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpathikrit%2Farraydeque-talk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpathikrit%2Farraydeque-talk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpathikrit%2Farraydeque-talk/lists"}