MeatAxe: Sets of Integers.

MeatAxe 2.4

- Main Page
- Related Pages
- Modules
- Data Structures

Data Structures | Functions
Sets of Integers.

## Data Structures
class | Set_t
| A Set of Integers. More...
## Functions
int | SetIsValid (const Set_t *s)
| Check a set.
Set_t * | SetAlloc ()
| Create a new set.
int | SetFree (Set_t *x)
| Destroy a set.
Set_t * | SetDup (const Set_t *s)
| Duplicate a set.
int | SetInsert (Set_t *set, long elem)
| Insert an element into a set.
int | SetPrint (char *name, const Set_t *s)
| Write a Set to the Standar Output.
int | SetContains (const Set_t *set, long elem)
| Check if a number is in a set.

## Function Documentation

Set_t* SetAlloc | ( |  | ) |

Create a new set.

This function creates a new, empty set. To destroy a set, use SetFree(), not SysFree().

Returns:
  Pointer to the new set or 0 on error.

int SetContains | ( | const Set_t * | set,
|  | long | elem
| ) |  |

Check if a number is in a set.

Parameters:

  set | Pointer to the set.
  elem | Number to check.

Returns:
  1 if the set contains elem, 0 if not.

Set_t* SetDup | ( | const Set_t * | s | ) |

Duplicate a set.

Parameters:

  s | Pointer to the set.

Returns:
  Pointer to a copy of the set, or 0 on error.

int SetFree | ( | Set_t * | x | ) |

Destroy a set.

This function frees an integer set. The argument must be a Set_t structure which has previously been allocated with SetAlloc().

Parameters:

  x | Pointer to the set.

Returns:
  0 on success, -1 on error.

int SetInsert | ( | Set_t * | set,
|  | long | elem
| ) |  |

Insert an element into a set.

Parameters:

  set | Pointer to the set.
  elem | Number to insert.

Returns:
  0 on success, -1 on error.

int SetIsValid | ( | const Set_t * | s | ) |

Check a set.

This function checks if the argument is a valid set. If the set is o.k., the function returns 1. Otherwise, an error is signaled and, if the error handler does not terminate the program, the function returns 0.

Parameters:

  s | Pointer to the set.

Returns:
  1 if s is a valid set, 0 otherwise.

int SetPrint | ( | char * | name,
|  | const Set_t * | s
| ) |  |

Write a Set to the Standar Output.

This function prints a set in human-readable format on the standard output. If name is different from 0, name and a "=" is printed before the set.

Parameters:

  name | Name to print before the set or 0.
  s | Pointer to the set.