dokan_vector.h
1 /*
2  Dokan : user-mode file system library for Windows
3 
4  Copyright (C) 2016 Keith Newton
5  Copyright (C) 2022 - 2023 Google, Inc.
6 
7  http://dokan-dev.github.io
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free
11 Software Foundation; either version 3 of the License, or (at your option) any
12 later version.
13 
14 This program is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License along
19 with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #ifndef DOKAN_VECTOR_H_
23 #define DOKAN_VECTOR_H_
24 
25 typedef struct _DOKAN_VECTOR {
26  PVOID Items;
27  size_t ItemCount;
28  size_t ItemSize;
29  size_t MaxItems;
30  BOOL IsStackAllocated;
31 } DOKAN_VECTOR, *PDOKAN_VECTOR;
32 
33 // Creates a new instance of DOKAN_VECTOR with default values.
34 DOKAN_VECTOR *DokanVector_Alloc(size_t ItemSize);
35 
36 // Creates a new instance of DOKAN_VECTOR with default values.
37 DOKAN_VECTOR *DokanVector_AllocWithCapacity(size_t ItemSize, size_t MaxItems);
38 
39 // Releases the memory associated with a DOKAN_VECTOR;
40 VOID DokanVector_Free(PDOKAN_VECTOR Vector);
41 
42 // Appends an item to the vector at the Front. Expensive, please use PushBack instead.
43 BOOL DokanVector_PushFront(PDOKAN_VECTOR Vector, PVOID Item);
44 
45 // Appends an item to the vector.
46 BOOL DokanVector_PushBack(PDOKAN_VECTOR Vector, PVOID Item);
47 
48 // Appends an array of items to the vector.
49 BOOL DokanVector_PushBackArray(PDOKAN_VECTOR Vector, PVOID Items, size_t Count);
50 
51 // Removes an item from the end of the vector.
52 VOID DokanVector_PopBack(PDOKAN_VECTOR Vector);
53 
54 // Removes multiple items from the end of the vector.
55 VOID DokanVector_PopBackArray(PDOKAN_VECTOR Vector, size_t Count);
56 
57 // Clears all items in the vector.
58 VOID DokanVector_Clear(PDOKAN_VECTOR Vector);
59 
60 // Retrieves the item at the specified index
61 PVOID DokanVector_GetItem(PDOKAN_VECTOR Vector, size_t Index);
62 
63 // Retrieves the last item the vector.
64 PVOID DokanVector_GetLastItem(PDOKAN_VECTOR Vector);
65 
66 // Retrieves the number of items in the vector.
67 size_t DokanVector_GetCount(PDOKAN_VECTOR Vector);
68 
69 // Retrieves the current capacity of the vector.
70 size_t DokanVector_GetCapacity(PDOKAN_VECTOR Vector);
71 
72 // Retrieves the size of items within the vector.
73 size_t DokanVector_GetItemSize(PDOKAN_VECTOR Vector);
74 
75 #endif
Definition: dokan_vector.h:25