{"id":13420430,"url":"https://github.com/y-256/libdivsufsort","last_synced_at":"2026-02-23T04:32:52.749Z","repository":{"id":28877765,"uuid":"32402214","full_name":"y-256/libdivsufsort","owner":"y-256","description":"A lightweight suffix-sorting library","archived":false,"fork":false,"pushed_at":"2020-03-25T16:44:59.000Z","size":264,"stargazers_count":398,"open_issues_count":18,"forks_count":89,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-12-10T06:16:13.548Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","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/y-256.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-17T15:30:25.000Z","updated_at":"2025-12-03T11:26:46.000Z","dependencies_parsed_at":"2022-08-27T19:11:36.136Z","dependency_job_id":null,"html_url":"https://github.com/y-256/libdivsufsort","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/y-256/libdivsufsort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y-256%2Flibdivsufsort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y-256%2Flibdivsufsort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y-256%2Flibdivsufsort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y-256%2Flibdivsufsort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/y-256","download_url":"https://codeload.github.com/y-256/libdivsufsort/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y-256%2Flibdivsufsort/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29738079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T02:24:00.660Z","status":"ssl_error","status_checked_at":"2026-02-23T02:22:56.087Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-07-30T22:01:33.528Z","updated_at":"2026-02-23T04:32:52.721Z","avatar_url":"https://github.com/y-256.png","language":"C","funding_links":[],"categories":["TODO scan for Android support in followings"],"sub_categories":[],"readme":"# libdivsufsort\n\nlibdivsufsort is a software library that implements a lightweight suffix array construction algorithm.\n\n## News\n* 2015-03-21: The project has moved from [Google Code](http://code.google.com/p/libdivsufsort/) to [GitHub](https://github.com/y-256/libdivsufsort)\n\n## Introduction\nThis library provides a simple and an efficient C API to construct a suffix array and a Burrows-Wheeler transformed string from a given string over a constant-size alphabet.\nThe algorithm runs in O(n log n) worst-case time using only 5n+O(1) bytes of memory space, where n is the length of\nthe string.\n\n## Build requirements\n* An ANSI C Compiler (e.g. GNU GCC)\n* [CMake](http://www.cmake.org/ \"CMake\") version 2.4.2 or newer\n* CMake-supported build tool\n\n## Building on GNU/Linux\n1. Get the source code from GitHub. You can either\n    * use git to clone the repository\n    ```\n    git clone https://github.com/y-256/libdivsufsort.git\n    ```\n    * or download a [zip file](../../archive/master.zip) directly\n2. Create a `build` directory in the package source directory.\n```shell\n$ cd libdivsufsort\n$ mkdir build\n$ cd build\n```\n3. Configure the package for your system.\nIf you want to install to a different location,  change the -DCMAKE_INSTALL_PREFIX option.\n```shell\n$ cmake -DCMAKE_BUILD_TYPE=\"Release\" \\\n-DCMAKE_INSTALL_PREFIX=\"/usr/local\" ..\n```\n4. Compile the package.\n```shell\n$ make\n```\n5. (Optional) Install the library and header files.\n```shell\n$ sudo make install\n```\n\n## API\n```c\n/* Data types */\ntypedef int32_t saint_t;\ntypedef int32_t saidx_t;\ntypedef uint8_t sauchar_t;\n\n/*\n * Constructs the suffix array of a given string.\n * @param T[0..n-1] The input string.\n * @param SA[0..n-1] The output array or suffixes.\n * @param n The length of the given string.\n * @return 0 if no error occurred, -1 or -2 otherwise.\n */\nsaint_t\ndivsufsort(const sauchar_t *T, saidx_t *SA, saidx_t n);\n\n/*\n * Constructs the burrows-wheeler transformed string of a given string.\n * @param T[0..n-1] The input string.\n * @param U[0..n-1] The output string. (can be T)\n * @param A[0..n-1] The temporary array. (can be NULL)\n * @param n The length of the given string.\n * @return The primary index if no error occurred, -1 or -2 otherwise.\n */\nsaidx_t\ndivbwt(const sauchar_t *T, sauchar_t *U, saidx_t *A, saidx_t n);\n```\n\n## Example Usage\n```c\n#include \u003cstdio.h\u003e\n#include \u003cstdlib.h\u003e\n#include \u003cstring.h\u003e\n\n#include \u003cdivsufsort.h\u003e\n\nint main() {\n    // intput data\n    char *Text = \"abracadabra\";\n    int n = strlen(Text);\n    int i, j;\n\n    // allocate\n    int *SA = (int *)malloc(n * sizeof(int));\n\n    // sort\n    divsufsort((unsigned char *)Text, SA, n);\n\n    // output\n    for(i = 0; i \u003c n; ++i) {\n        printf(\"SA[%2d] = %2d: \", i, SA[i]);\n        for(j = SA[i]; j \u003c n; ++j) {\n            printf(\"%c\", Text[j]);\n        }\n        printf(\"$\\n\");\n    }\n\n    // deallocate\n    free(SA);\n\n    return 0;\n}\n```\nSee the [examples](examples) directory for a few other examples.\n\n## Benchmarks\nSee [Benchmarks](https://github.com/y-256/libdivsufsort/blob/wiki/SACA_Benchmarks.md) page for details.\n\n## License\nlibdivsufsort is released under the [MIT license](LICENSE \"MIT license\").\n\u003e The MIT License (MIT)\n\u003e\n\u003e Copyright (c) 2003 Yuta Mori All rights reserved.\n\u003e\n\u003e Permission is hereby granted, free of charge, to any person obtaining a copy\n\u003e of this software and associated documentation files (the \"Software\"), to deal\n\u003e in the Software without restriction, including without limitation the rights\n\u003e to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\u003e copies of the Software, and to permit persons to whom the Software is\n\u003e furnished to do so, subject to the following conditions:\n\u003e\n\u003e The above copyright notice and this permission notice shall be included in all\n\u003e copies or substantial portions of the Software.\n\u003e\n\u003e THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\u003e IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\u003e FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\u003e AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\u003e LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\u003e OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n\u003e SOFTWARE.\n\n## Author\n* Yuta Mori\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fy-256%2Flibdivsufsort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fy-256%2Flibdivsufsort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fy-256%2Flibdivsufsort/lists"}