reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
hashset.h
Go to the documentation of this file.
1/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2012 Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * Modified in 2022 by Edward A. Lee to conform to documentation standards.
18 * Also, changed so that hashset_create() takes an initial capacity argument.
19 */
20
21#ifndef HASHSET_H
22#define HASHSET_H 1
23
24#include <stdlib.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30struct hashset_st {
31 size_t nbits;
32 size_t mask;
33
34 size_t capacity;
35 void** items;
36 size_t nitems;
38};
39
40typedef struct hashset_st* hashset_t;
41
48hashset_t hashset_create(unsigned short nbits);
49
54
59
67int hashset_add(hashset_t set, void* item);
68
74int hashset_remove(hashset_t set, void* item);
75
79int hashset_is_member(hashset_t set, void* item);
80
81#ifdef __cplusplus
82}
83#endif
84
85#endif
hashset_t hashset_create(unsigned short nbits)
Create a hashset instance. The returned value is a pointer. The caller must call hashset_destroy() to...
Definition hashset.c:29
int hashset_add(hashset_t set, void *item)
Add a pointer to the hashset. Note that 0 and 1 are special values, meaning nil and deleted items....
Definition hashset.c:117
int hashset_is_member(hashset_t set, void *item)
Returns non-zero if the item is in the hashset and zero otherwise.
Definition hashset.c:139
int hashset_remove(hashset_t set, void *item)
Remove an item from the hashset. Return non-zero if the item was removed and zero if the item is not ...
Definition hashset.c:123
void hashset_destroy(hashset_t set)
Destroy the hashset instance, freeing allocated memory.
Definition hashset.c:50
size_t hashset_num_items(hashset_t set)
Return the number of items in the hashset.
Definition hashset.c:48
struct hashset_st * hashset_t
Definition hashset.h:40
Definition hashset.h:30
void ** items
Definition hashset.h:35
size_t capacity
Definition hashset.h:34
size_t n_deleted_items
Definition hashset.h:37
size_t nitems
Definition hashset.h:36
size_t mask
Definition hashset.h:32
size_t nbits
Definition hashset.h:31