51Degrees Common C/C++  4.1

A shared functionality library that is used by 51Degrees products

list.h

1 /* *********************************************************************
2  * This Source Code Form is copyright of 51 Degrees Mobile Experts Limited.
3  * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4  * Caversham, Reading, Berkshire, United Kingdom RG4 7BY
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0.
8  *
9  * If a copy of the MPL was not distributed with this file, You can obtain
10  * one at http://mozilla.org/MPL/2.0/.
11  *
12  * This Source Code Form is "Incompatible With Secondary Licenses", as
13  * defined by the Mozilla Public License, v. 2.0.
14  * ******************************************************************** */
15 
16 #ifndef FIFTYONE_DEGREES_LIST_H_INCLUDED
17 #define FIFTYONE_DEGREES_LIST_H_INCLUDED
18 
98 #include "collection.h"
99 #include "string.h"
100 
101 #ifdef __cplusplus
102 #define EXTERNAL extern "C"
103 #else
104 #define EXTERNAL
105 #endif
106 
110 typedef struct fiftyone_degrees_list_t {
112  uint32_t capacity;
113  uint32_t count;
115 
123  fiftyoneDegreesList *list,
124  uint32_t capacity);
125 
132 EXTERNAL void fiftyoneDegreesListAdd(
133  fiftyoneDegreesList *list,
135 
143  fiftyoneDegreesList *list,
144  int index);
145 
151 EXTERNAL void fiftyoneDegreesListFree(fiftyoneDegreesList *list);
152 
157 EXTERNAL void fiftyoneDegreesListReset(fiftyoneDegreesList *list);
158 
164 
169 #endif
EXTERNAL void fiftyoneDegreesListFree(fiftyoneDegreesList *list)
Frees the memory allocated to the list structure and release all items stored in it.
Definition: list.c:60
Used to store a handle to the underlying item that could be used to release the item when it's finish...
Definition: collection.h:302
fiftyoneDegreesCollectionItem * items
Array of items.
Definition: list.h:111
uint32_t capacity
Capacity of the list to store items.
Definition: list.h:112
EXTERNAL fiftyoneDegreesString * fiftyoneDegreesListGetAsString(fiftyoneDegreesList *list, int index)
Gets the item at the index provided as a string.
Definition: list.c:40
EXTERNAL void fiftyoneDegreesListRelease(fiftyoneDegreesList *list)
Releases all the items stored in the list.
Definition: list.c:52
String structure containing its value and size.
Definition: string.h:80
EXTERNAL void fiftyoneDegreesListAdd(fiftyoneDegreesList *list, fiftyoneDegreesCollectionItem *item)
Adds a collection item to a list.
Definition: list.c:32
List structure which contains a list of collection items.
Definition: list.h:110
EXTERNAL void fiftyoneDegreesListReset(fiftyoneDegreesList *list)
Resets a newly allocated list to a clean empty state.
Definition: list.c:46
EXTERNAL fiftyoneDegreesList * fiftyoneDegreesListInit(fiftyoneDegreesList *list, uint32_t capacity)
Initialise the list by allocating space for the items in the list structure.
Definition: list.c:20
uint32_t count
Number of items currently in the list.
Definition: list.h:113