ZestCode
 
Loading...
Searching...
No Matches
set.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "kapi.h"

Go to the source code of this file.

Classes

struct  set
 

Functions

void set_initialize (struct set *const set)
 
bool set_add (struct set *const set, uint32_t item)
 
bool set_rm (struct set *const set, uint32_t item)
 
bool set_contains (struct set *set, uint32_t item)
 
bool list_contains (uint32_t const *const list, const size_t size, const uint32_t item)
 

Detailed Description

Kernel-allocated thread-safe simple sets header

See common/set.c for discussion

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Function Documentation

◆ list_contains()

bool list_contains ( uint32_t const *const list,
const size_t size,
const uint32_t item )

Checks if the list contains an item

Parameters
listA pointer to a list of words
sizeThe number of items in the list
itemThe item to check
Returns
True if the item is in the list

◆ set_add()

bool set_add ( struct set *const set,
uint32_t item )

Adds item to the set if it didn't already exist

Parameters
setA pointer to the set structure
itemItem to add to the set
Returns
Ttrue if the item was added to the set or was already present

◆ set_contains()

bool set_contains ( struct set * set,
uint32_t item )

Checks if the set contains an item

Parameters
setA pointer to the set structure
itemThe item to check
Returns
True if the item is in the set

◆ set_initialize()

void set_initialize ( struct set *const set)

Initializes a a set.

Parameters
setA pointer to a set structure

◆ set_rm()

bool set_rm ( struct set *const set,
uint32_t item )

Removes an item from the set

Parameters
setA pointer to the set structure
itemThe item to remove
Returns
True if the item was removed (or was already not present)