libFirm 1.20
libfirm/adt/pset_new.h File Reference

hashset containing pointers More...

#include "../begin.h"
#include "hashset.h"
#include "../end.h"

Go to the source code of this file.

Defines

#define foreach_pset_new(pset_new, type, ptr, iter)
 Convenience macro for iterating over a pset_new.

Typedefs

typedef struct pset_new_t pset_new_t
 a pointer (hash)set
typedef struct pset_new_iterator_t pset_new_iterator_t
 iterator over a pointer set.

Functions

void pset_new_init (pset_new_t *pset_new)
 Initializes a pset_new.
void pset_new_init_size (pset_new_t *pset_new, size_t expected_elements)
 Initializes a pset_new.
void pset_new_destroy (pset_new_t *pset_new)
 Destroys a pset_new and frees the memory allocated for hashtable.
int pset_new_insert (pset_new_t *pset_new, void *ptr)
 Inserts an element into a pset_new.
void pset_new_remove (pset_new_t *pset_new, const void *ptr)
 Removes an element from a pset_new.
int pset_new_contains (const pset_new_t *pset_new, const void *ptr)
 Tests whether a pset_new contains a pointer.
size_t pset_new_size (const pset_new_t *pset_new)
 Returns the number of pointers contained in the pset_new.
void pset_new_iterator_init (pset_new_iterator_t *iterator, const pset_new_t *pset_new)
 Initializes a pset_new iterator.
void * pset_new_iterator_next (pset_new_iterator_t *iterator)
 Advances the iterator and returns the current element or NULL if all elements in the pset_new have been processed.
void pset_new_remove_iterator (pset_new_t *pset_new, const pset_new_iterator_t *iterator)
 Removes the element that the iterator currently points to from the hashset.

Detailed Description

hashset containing pointers

Date:
17.03.2007
Author:
Matthias Braun
Note:
This has been named pset_new_new for now until all code has been changed to use this instead of the old deprecated pset_new functions! This version performs better than pset in terms of speed and memory usage and allows multiple iterators over the set

Definition in file pset_new.h.


Define Documentation

#define foreach_pset_new (   pset_new,
  type,
  ptr,
  iter 
)
Value:
for(pset_new_iterator_init(&iter, pset_new), \
        ptr = (type) pset_new_iterator_next(&iter);     \
        ptr != NULL; ptr = (type) pset_new_iterator_next(&iter))

Convenience macro for iterating over a pset_new.

Definition at line 145 of file pset_new.h.


Typedef Documentation

iterator over a pointer set.

See also:
pset_new_t

Definition at line 54 of file pset_new.h.

typedef struct pset_new_t pset_new_t

a pointer (hash)set

Definition at line 51 of file pset_new.h.


Function Documentation

int pset_new_contains ( const pset_new_t pset_new,
const void *  ptr 
)

Tests whether a pset_new contains a pointer.

Parameters:
pset_newPointer to the pset_new
ptrThe pointer to test
Returns:
1 pset_new contains the ptr, 0 otherwise
void pset_new_destroy ( pset_new_t pset_new)

Destroys a pset_new and frees the memory allocated for hashtable.

The memory of the pset_new itself is not freed.

Parameters:
pset_newPointer to the pset_new
void pset_new_init ( pset_new_t pset_new)

Initializes a pset_new.

Parameters:
pset_newPointer to allocated space for the pset_new
void pset_new_init_size ( pset_new_t pset_new,
size_t  expected_elements 
)

Initializes a pset_new.

Parameters:
pset_newPointer to allocated space for the pset_new
expected_elementsNumber of elements expected in the pset_new (roughly)
int pset_new_insert ( pset_new_t pset_new,
void *  ptr 
)

Inserts an element into a pset_new.

Parameters:
pset_newPointer to the pset_new
ptrPointer to insert into the pset_new
Returns:
1 if the pointer was inserted, 0 if it was already there
void pset_new_iterator_init ( pset_new_iterator_t iterator,
const pset_new_t pset_new 
)

Initializes a pset_new iterator.

Sets the iterator before the first element in the pset_new.

Parameters:
iteratorPointer to already allocated iterator memory
pset_newPointer to the pset_new
void* pset_new_iterator_next ( pset_new_iterator_t iterator)

Advances the iterator and returns the current element or NULL if all elements in the pset_new have been processed.

Attention:
It is not allowed to use pset_new_insert or pset_new_remove while iterating over a pset_new; pset_new_remove_iter is allowed.
Parameters:
iteratorPointer to the pset_new iterator.
Returns:
Next element in the pset_new or NULL
void pset_new_remove ( pset_new_t pset_new,
const void *  ptr 
)

Removes an element from a pset_new.

Does nothing if the pset_new doesn't contain the element.

Parameters:
pset_newPointer to the pset_new
ptrPointer to remove from the pset_new
void pset_new_remove_iterator ( pset_new_t pset_new,
const pset_new_iterator_t iterator 
)

Removes the element that the iterator currently points to from the hashset.

Parameters:
pset_newPointer to the pset_new
iteratorPointer to the iterator
size_t pset_new_size ( const pset_new_t pset_new)

Returns the number of pointers contained in the pset_new.

Parameters:
pset_newPointer to the pset_new
Returns:
Number of pointers contained in the pset_new