reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
hashset.h File Reference

A hash set implementation in C. More...

#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  hashset_st
 A hashset. More...

Typedefs

typedef struct hashset_sthashset_t

Functions

int hashset_add (hashset_t set, void *item)
 Add a pointer to the hashset.
hashset_t hashset_create (unsigned short nbits)
 Create a hashset instance.
void hashset_destroy (hashset_t set)
 Destroy the hashset instance, freeing allocated memory.
int hashset_is_member (hashset_t set, void *item)
 Returns non-zero if the item is in the hashset and zero otherwise.
size_t hashset_num_items (hashset_t set)
 Return the number of items in the hashset.
int hashset_remove (hashset_t set, void *item)
 Remove an item from the hashset.

Detailed Description

A hash set implementation in C.

This is a modified version of the hash set implementation in C from: https://github.com/avsej/hashset.c

Example usage:

#include "hashset.h"
char *foo = "foo";
char *missing = "missing";
if (set == NULL) {
fprintf(stderr, "failed to create hashset instance\n");
abort();
}
hashset_add(set, foo);
assert(hashset_is_member(set, foo) == 1);
assert(hashset_is_member(set, missing) == 0);
hashset_t hashset_create(unsigned short nbits)
Create a hashset instance.
int hashset_add(hashset_t set, void *item)
Add a pointer to the hashset.
int hashset_is_member(hashset_t set, void *item)
Returns non-zero if the item is in the hashset and zero otherwise.
A hash set implementation in C.
struct hashset_st * hashset_t
Definition hashset.h:73

The corresponding .c files are in reactor-c/core/utils/hashset

License

Copyright 2012 Couchbase, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Modified in 2022 by Edward A. Lee to conform to documentation standards. Also, changed so that hashset_create() takes an initial capacity argument.

Typedef Documentation

◆ hashset_t

typedef struct hashset_st* hashset_t