An ordered expandable collection of dynamically allocated Product records.
More...
#include <Pool.h>
|
| struct Pool * | pool_create (const unsigned int initial_capacity, const float growth_factor) |
| | Create a new empty Pool with the given initial capacity and growth factor.
|
| |
| void | pool_delete (struct Pool **this) |
| | Destroy the Pool and all held Product objects.
|
| |
| bool | pool_insert_element (struct Pool *this, struct Product *product) |
| | Insert the given Product into the Pool, expanding the Pool by its growth factor if necessary.
|
| |
| int | pool_serialise_report (const struct Pool *this, FILE *buffer) |
| | Serialise the contents of the Pool, with an additional header, to the given stream, in the report format.
|
| |
| int | pool_serialise_stock_file (const struct Pool *this, FILE *buffer) |
| | Serialise the contents of the Pool, with an additional header, to the given stream, in the stock file format.
|
| |
| struct Product * | pool_get_product_by_index (const struct Pool *this, unsigned int index) |
| | Retrieve the Product at the stated index in the pool.
|
| |
|
| static void | print_dashed_header (FILE *const buffer) |
| | Print the common header separator consisting of repeated hyphens.
|
| |
An ordered expandable collection of dynamically allocated Product records.
Definition at line 24 of file Pool.c.
◆ pool_create()
| struct Pool * pool_create |
( |
const unsigned int |
initial_capacity, |
|
|
const float |
growth_factor |
|
) |
| |
Create a new empty Pool with the given initial capacity and growth factor.
- Parameters
-
| initial_capacity | The initial number of Product instances that the Pool may accommodate. |
| growth_factor | The multiplicative factor by which the Pool capacity should grow when expanded. |
- Returns
- The dynamically allocated Pool.
Definition at line 46 of file Pool.c.
◆ pool_delete()
| void pool_delete |
( |
struct Pool ** |
this | ) |
|
◆ pool_get_product_by_index()
| struct Product * pool_get_product_by_index |
( |
const struct Pool * |
this, |
|
|
unsigned int |
index |
|
) |
| |
Retrieve the Product at the stated index in the pool.
- Parameters
-
- Returns
- The Product at the requested index, or NULL if there was no suitable Product.
Definition at line 140 of file Pool.c.
◆ pool_insert_element()
| bool pool_insert_element |
( |
struct Pool * |
this, |
|
|
struct Product * |
product |
|
) |
| |
Insert the given Product into the Pool, expanding the Pool by its growth factor if necessary.
- Parameters
-
- Returns
- Was the Product successfully inserted into the Pool?
Definition at line 78 of file Pool.c.
◆ pool_serialise_report()
| int pool_serialise_report |
( |
const struct Pool * |
this, |
|
|
FILE * |
buffer |
|
) |
| |
Serialise the contents of the Pool, with an additional header, to the given stream, in the report format.
- Parameters
-
| this | The Pool to serialise. |
| buffer | The destination buffer to which the serialised Pool data should be written. |
- Returns
- The number of bytes written, negative if and only if an error occurred. In the latter case, errno is set.
Definition at line 102 of file Pool.c.
◆ pool_serialise_stock_file()
| int pool_serialise_stock_file |
( |
const struct Pool * |
this, |
|
|
FILE * |
buffer |
|
) |
| |
Serialise the contents of the Pool, with an additional header, to the given stream, in the stock file format.
- Parameters
-
| this | The Pool to serialise. |
| buffer | The destination buffer to which the serialised Pool data should be written. |
- Returns
- The number of bytes written, negative if and only if an error occurred. In the latter case, errno is set.
Definition at line 128 of file Pool.c.
◆ print_dashed_header()
| static void print_dashed_header |
( |
FILE *const |
buffer | ) |
|
|
staticprivate |
Print the common header separator consisting of repeated hyphens.
- Parameters
-
| buffer | The buffer to which the separator bytes should be written. |
Definition at line 37 of file Pool.c.
◆ capacity
| unsigned int Pool::capacity |
Maximum capacity of the Pool.
Definition at line 26 of file Pool.c.
◆ growth_factor
| float Pool::growth_factor |
◆ index
◆ products
The documentation for this struct was generated from the following files: