{"id":23503509,"url":"https://github.com/realyuniquename/bits","last_synced_at":"2025-05-05T16:21:54.416Z","repository":{"id":151066516,"uuid":"172359976","full_name":"RealyUniqueName/Bits","owner":"RealyUniqueName","description":"Binary bit flags with unlimited amount of bits","archived":false,"fork":false,"pushed_at":"2019-02-28T14:37:32.000Z","size":22,"stargazers_count":23,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-01T14:40:40.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haxe","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/RealyUniqueName.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-02-24T16:16:46.000Z","updated_at":"2024-05-19T20:14:18.000Z","dependencies_parsed_at":"2024-01-03T03:54:00.195Z","dependency_job_id":"68d37c71-7d6a-4698-9784-e8ba24a700f3","html_url":"https://github.com/RealyUniqueName/Bits","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealyUniqueName%2FBits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealyUniqueName%2FBits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealyUniqueName%2FBits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealyUniqueName%2FBits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RealyUniqueName","download_url":"https://codeload.github.com/RealyUniqueName/Bits/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252531882,"owners_count":21763293,"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-12-25T08:30:01.686Z","updated_at":"2025-05-05T16:21:54.393Z","avatar_url":"https://github.com/RealyUniqueName.png","language":"Haxe","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bits\n\nThis lib aims to implement binary bit flags in Haxe with unlimited amount of bits per instance.\n\n```haxe\nvar flags = new bits.Bits();\n\nflags.set(2); // set a bit at position 2 (zero-based)\nflags.set(5);\n\nflags.toString(); // \"10010\"\n\nflags.isSet(2); // true\nflags.areSet([2, 5]); // true;\n\nflags.set(9999);\nflags.isSet(9999); // true\n```\n`bits.Bits` is implemented as an abstract over `Array\u003cInt\u003e`. Each item of that array is used to store 32 flags.\n\n### API\n\n```haxe\n/**\n * Create a `bits.Bits` instance using values of `positions` as positions of bits, which should be set to 1.\n * E.g. `[0, 2, 7]` will produce `bits.Bits` instance of `10000101`.\n * If there is a negative value in `positions` the result is unspecified.\n */\n@:from static public function fromPositions(positions:Array\u003cInt\u003e):Bits;\n\n/**\n * Create a new instance.\n *\n * By default the new instance allocates a memory for 32 (on most platforms) bits.\n * And then grows as necessary on setting bits at positions greater than 31.\n *\n * @param capacity makes `bits.Bits` to pre-allocate the amount of memory required to store `capacity` bits.\n */\npublic inline function new(capacity:Int = 0);\n\n/**\n * Set the bit at position `pos` (zero-based) in a binary representation of `bits.BitFlags` to 1.\n * It's like `bits = bits | (1 \u003c\u003c pos)`\n * E.g. if `pos` is 2 the third bit is set to 1 (`0000100`).\n * If `pos` is negative the result is unspecified.\n */\npublic function set(pos:Int):Void;\n\n/**\n * Set the bit at position `pos` (zero-based) in a binary representation of `bits.BitFlags` to 0.\n * If `pos` is negative the result is unspecified.\n */\npublic function unset(pos:Int):Void;\n\n/**\n * Add all ones of `bits` to this instance.\n * It's like `this = this | bits`.\n */\npublic function add(bits:Bits):Void;\n\n/**\n * Remove all ones of `bits` from this instance.\n * It's like `this = this \u0026 ~bits`.\n */\npublic function remove(bits:Bits):Void;\n\n/**\n * Check if a bit at position `pos` is set to 1.\n * If `pos` is negative the result is unspecified.\n */\npublic function isSet(pos:Int):Bool;\n\n/**\n * Check if this instance has all the corresponding bits of `bits` set.\n * It's like `this \u0026 bits != 0`.\n * E.g. returns `true` if `this` is `10010010` and `bits` is `10000010`.\n */\npublic function areSet(bits:Bits):Bool;\n\n/**\n * Invoke `callback` for each non-zero bit.\n * Callback will receive a position (zero-based) of each non-zero bit.\n */\npublic inline function forEach(callback:Int-\u003eVoid):Void;\n\n/**\n * Create a copy of this instance\n */\npublic inline function copy():Bits;\n\n/**\n * Get string representation of this instance (without leading zeros).\n * E.g. `100010010`.\n */\npublic function toString():String;\n\n/**\n * Count the amount of non-zero bits.\n */\npublic function count():Int;\n\n/**\n * Check if all bits are zeros\n */\npublic function isEmpty():Bool;\n\n/**\n * Set all bits to 0\n */\npublic function clear():Void;\n\n/**\n * Merge this instance with `bits`.\n * E.g. merging `10010` and `10001` produces `10011`.\n * Creates a new `bits.Bits` instance.\n */\n@:op(A | B) public function merge(bits:Bits):Bits;\n\n/**\n * Returns an intersection of this instance with `bits`.\n * E.g. intersecting `10010` and `01010` produces `00010`.\n * Creates a new `bits.Bits` instance.\n */\n@:op(A \u0026 B) public function intersect(bits:Bits):Bits;\n\n/**\n * Iterator over the positions of non-zero bits\n */\npublic inline function iterator():BitsIterator;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealyuniquename%2Fbits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealyuniquename%2Fbits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealyuniquename%2Fbits/lists"}