{"id":16374974,"url":"https://github.com/moderocky/clockwork","last_synced_at":"2025-06-21T05:01:57.798Z","repository":{"id":103957104,"uuid":"600401089","full_name":"Moderocky/Clockwork","owner":"Moderocky","description":"A logic, collections and data library.","archived":false,"fork":false,"pushed_at":"2024-01-10T11:14:00.000Z","size":118,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-02T05:04:56.087Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/Moderocky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-11T11:31:29.000Z","updated_at":"2023-05-29T07:36:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"5f11ca5c-bd1f-40c4-9b3b-66dfe1f20c3d","html_url":"https://github.com/Moderocky/Clockwork","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Moderocky/Clockwork","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FClockwork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FClockwork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FClockwork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FClockwork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Moderocky","download_url":"https://codeload.github.com/Moderocky/Clockwork/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FClockwork/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261065242,"owners_count":23104761,"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-11T03:19:00.915Z","updated_at":"2025-06-21T05:01:52.776Z","avatar_url":"https://github.com/Moderocky.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Clockwork\n=====\n\n### Opus #23\n\nA logic, collections and data library.\n\n## Features\n\n### Table\n\nA fixed-size two-dimensional grid of typed entries. \\\nElements are stored according to `(x, y)` coordinates in columns and rows.\n\n`Table`s also function as a collection, so the entire element set can be iterated over.\n\n#### Making a Table\n\nA table can be created with a type, width and length.\n\n```java\nfinal Table\u003cString\u003e table=new Table\u003c\u003e(String.class,3,2);\n```\n\nThis will create a `3` by `2` table. All entries will start as `null`.\n\n```\n0 2 4\n1 3 5\n```\n\nYou can also create a table with an initial array of elements, which are entered by index number.\n\n```java\nfinal Table\u003cString\u003e table=new Table\u003c\u003e(3,2,\"A\",\"B\",\"C\");\n```\n\nThis will create a `3` by `2` table and enter the initial data.\nIf the data set is smaller than the table capacity remaining slots will be `null`.\nIf the data set exceeds the table capacity then remaining entries will be ignored.\n\n```\nA C -\nB - -\n```\n\n#### Accessing Data\n\nThere are **three** ways to directly access data from a table.\n\nAn element can be accessed via its index in the entire table. This indexing reads vertically, one column at a time.\n\n```java\ntable.set(2,\"hello\");\n```\n\n```java\ntable.get(14);\n```\n\nAn element can be accessed by its grid coordinates. This is the fastest access method. \\\nN.B. we go horizontally then vertically.\n\n```java\ntable.get(20,35);\n```\n\n```java\ntable.set(22,41,\"hello\");\n```\n\nA row or column can be accessed as a unit, and then individual elements can be obtained by index in it.\n\n```java\ntable.row(0).get(1);\n```\n\n```java\ntable.column(3).set(4,\"hello\");\n```\n\nRow and column iterators reflect changes on the table itself.\n\n### Fixed Array List\n\nA list implementation with a constant backing array and a fixed capacity.\n\n#### Capacity\n\nFixed array lists can hold a set number of elements, shown by `list.capacity()`. \\\nIf a list is full, it can be checked with `list.isFull()`.\n\n#### Creation\n\nFixed array lists can either be given an array `new FixedArrayList\u003c\u003e(array)` which specifies its size and initial\nelements,\nor can be given both separately `new FixedArrayList\u003c\u003e(5, ...)`.\n\nIn either case, the elements will be shuffled into a continuous order and the pointer will be marked at the end.\nThis means the list does **not** support `null` elements during creation:\nit would be impossible to tell whether the user supplied an empty array to mark the size, or an array full of genuine,\nexpected `null` values.\n\nThe list supports `null` elements in subsequent additions.\n\n### Clock List\n\nA simple list type with some useful features. \\\n`ClockList`s are backed by another list, typically an `ArrayList`.\n\n#### Known Type\n\nUnlike regular lists, they have a fixed type defined at creation. This can be obtained with `list.getType()`.\nThis type aids in serialisation- all elements conform to it.\n\nThe list type is either provided through the constructors (`new ClockList\u003c\u003e(type)` or `new ClockList\u003c\u003e(type, list)`) or\nthrough compiler magic via an array `new ClockList\u003c\u003e()`.\n\nKnowing the type allows easier array creation `String[] = list.toArray()` and allows this list to be serialised in\ntype-specific array formats.\n\n#### Random Element\n\nClock lists have a simple `list.getRandom()` element getter that can accept a random source.\n\n#### Clone\n\nClock lists can be cloned, which creates a new list object and a new backing list, allowing elements to be removed from\nthe clone without affecting the original.\n\n### Primitive List\n\nArray-based list implementations for primitive types. \\\nThese are designed to reduce unnecessary memory usage and increase performance\nin cases where number wrapper types are unnecessary.\n\nThese have the traditional list implementations that give and take values using wrappers.\nThese also have raw methods that use the primitive type directly.\n\nSome semantics deviate from the typical rules of lists - primitive lists (naturally) cannot hold `null` values.\nSome operations are not supported.\n\n### I/O Queue\n\nA single-entry task queue, designed for processing save/load tasks in sequence for environments where there is a risk of\nconcurrent access.\n\nA `new IOQueue` can be obtained at any time, and should be stored in a field.\n\nData tasks can be queued using `queue.queue(task)`.\nThis will return a reference to the task, which can be used to `await()` from the program's thread, if the result is\nrequired immediately.\n\nWhen the queue is no longer required, it can be closed using the `shutdown(time)` method, which will try to process all\nremaining tasks and report any that fail to complete within the allotted time.\n\nTasks are protected from being queued twice, so it is advisable to keep a reference to data-specific save or load tasks\nin order to make use of this protection.\n\nA task is removed from the queue *before* its execution. This means that if a task needs to be re-queued during its\nexecution it can be.\n\nAn I/O queue uses a single task thread. This makes sure the same data store will never be accessed twice at the same\ntime. \\\nIf you are accessing multiple data stores, it is advisable to create separate queues for each, since there is no risk of\nconcurrent modification between them.\n\n### Magic Map\n\n**Note:** this requires Foundation 2 as a dependency.\n\nAn exceedingly fast `String -\u003e Object` map. \\\nThis implementation trades map creation time and flexibility for the fastest possible set/get access.\n\nA magic map has a fixed set of keys, defined when the map is created during runtime.\nA new map class is created with space allocated for each key.\n\n\u003e #### Example\n\u003e\n\u003e A magic map with the keys `foo` and `bar` would create something equivalent to:\n\u003e ```java \n\u003e class ? extends MagicMap {\n\u003e     Object foo, bar;\n\u003e }\n\u003e ```\n\u003e The fields can be accessed directly by name if you are interacting with this from another meta-compiler task.\n\nIn order to provide the required map behaviour, the `get` and `put` methods implement a fast lookup switch to access the\nfield.\n\n#### Access Helpers\n\nAn access helper interface can be provided for even faster access to an element, bypassing the lookup table.\n\n\u003e #### Example\n\u003e ```java \n\u003e import mx.kenzie.clockwork.collection.MagicMap;\n\u003e\n\u003e interface MyMap extends MagicMap.Accessor {\n\u003e\n\u003e     Object foo();\n\u003e\n\u003e     String bar();\n\u003e\n\u003e }\n\u003e ```\n\u003e When a map is created with this accessor, the `foo` and `bar` methods will be implemented to get the fields, and cast\n\u003e their values where appropriate.\n\u003e\n\u003e A setter can be made with an `Object name(Object value)` method.\n\n#### Extending a Map\n\nOne magic map can be made to extend another, by providing it as the super-type.\n\nIt will inherit all the keys (and extra behaviour) of its parent type.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoderocky%2Fclockwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoderocky%2Fclockwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoderocky%2Fclockwork/lists"}