CARVIEW |
Select Language
HTTP/2 200
date: Tue, 14 Oct 2025 06:28:54 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"168ca4424c2896764f4b3c43a1359cf8"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=9QALn0Ac1ZMYlDsMwHZuN6zJkpy7uchIu8aYki9RlJxFcakkrevY3Vx2m8jinEj%2B3NRqToK1QZ7sQVw6VaaAhLa73z%2FdwfFPQ1bp3%2BXEw9oMxk45VS6j0e0hfM7ZLs1cqTwEJu6mm6AcwaAPH%2Ba7OCA30pj27TNhqr6jCsu3Hr9kTjP8yYo6oXhRsDnk6XCn%2B16KBf%2BIdM6oqFRer4j1mH2uOji1CeE5R%2BH79RPYjf3yTGGpGSGOfZ3KfRNXT6GYbkjdqvdswc4V3yiSlay7Yw%3D%3D--HPSVviNp%2Bxk%2BKH6a--8RRt%2BmBczVMYYkHInfcjfw%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1039862969.1760423334; Path=/; Domain=github.com; Expires=Wed, 14 Oct 2026 06:28:54 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Wed, 14 Oct 2026 06:28:54 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 8B5C:50661:4AE055:5FB047:68EDEDA6
ust · glouw/ctl Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 117
ust
Gustav Louw edited this page Jan 17, 2021
·
5 revisions
#include <ust.h>
The CTL ust
, analogous to the std::unordered_set
, is a container specializing in fast O(1)
ideal time key-value lookup, erase, and insert operations. The ust
template is implemented as a contiguous resizable array of pointers to forward linked list nodes. Pointers to elements within an ust
remain valid as new elements are inserted and deleted to and from an ust
.
An ust
may be used in place of a set
when a performance gain at the cost of memory consumption is required.
#include <stdio.h>
#include <str.h>
#define T str
#include <ust.h>
size_t
str_hash(str* s)
{
size_t hash = 5381;
int c;
char* temp = s->value;
while(c = *temp++)
hash = ((hash << 5) + hash) + c;
return hash;
}
int
str_equal(str* a, str* b)
{
return str_key_compare(a, b) == 0;
}
int
main(void)
{
ust_str strs = ust_str_init(str_hash, str_equal);
ust_str_insert(&strs, str_init("this"));
ust_str_insert(&strs, str_init("is"));
ust_str_insert(&strs, str_init("a"));
ust_str_insert(&strs, str_init("test"));
ust_str_insert(&strs, str_init("for"));
ust_str_insert(&strs, str_init("unordered"));
ust_str_insert(&strs, str_init("set"));
ust_str_insert(&strs, str_init("for"));
ust_str_insert(&strs, str_init("the"));
ust_str_insert(&strs, str_init("C"));
ust_str_insert(&strs, str_init("Standard"));
ust_str_insert(&strs, str_init("Template"));
ust_str_insert(&strs, str_init("Library"));
ust_str_insert(&strs, str_init("(CTL)"));
ust_str_insert(&strs, str_init("..."));
foreach(ust_str, &strs, it)
puts(str_c_str(it.ref));
for(size_t i = 0; i < strs.bucket_count; i++)
printf("%2d : %2lu\n", i, ust_str_bucket_size(&strs, i));
str what = str_init("(CTL)");
str* found = &ust_str_find(&strs, what)->key;
puts(str_c_str(found));
ust_str_erase(&strs, what); // For fun.
str_free(&what);
ust_str_free(&strs);
}
gcc main.c -I ctl
Clone this wiki locally
You can’t perform that action at this time.