-
Notifications
You must be signed in to change notification settings - Fork 0
/
strList.h
112 lines (90 loc) · 2.49 KB
/
strList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#pragma once
#include <stdlib.h>
/********************************************************************************
*
* A StrList library.
*
* This library provides a StrList of STRINGS data structure.
*
* This library will fail in unpredictable ways when the system memory runs
* out.
*
********************************************************************************/
/*
* StrList represents a StrList data structure.
*/
struct _StrList;
typedef struct _StrList StrList;
/*
* Allocates a new empty StrList.
* It's the user responsibility to free it with StrList_free.
*/
StrList* StrList_alloc();
/*
* Frees the memory and resources allocated to StrList.
* If StrList==NULL does nothing (same as free).
*/
void StrList_free(StrList* StrList);
/*
* Returns the number of elements in the StrList.
*/
size_t StrList_size(const StrList* StrList);
/*
* Inserts an element in the end of the StrList.
*/
void StrList_insertLast(StrList* StrList,const char* data);
/*
* Inserts an element at given index
*/
void StrList_insertAt(StrList* StrList,const char* data,int index);
/*
* Returns the StrList first data.
*/
char* StrList_firstData(const StrList* StrList);
/*
* Prints the StrList to the standard output.
*/
void StrList_print(const StrList* StrList);
/*
Prints the word at the given index to the standard output.
*/
void StrList_printAt(const StrList* Strlist,int index);
/*
* Return the amount of chars in the list.
*/
int StrList_printLen(const StrList* Strlist);
/*
Given a string, return the number of times it exists in the list.
*/
int StrList_count(StrList* StrList, const char* data);
/*
Given a string and a list, remove all the appearances of this string in the list.
*/
void StrList_remove(StrList* StrList, const char* data);
/*
Given an index and a list, remove the string at that index.
*/
void StrList_removeAt(StrList* StrList, int index);
/*
* Checks if two StrLists have the same elements
* returns 0 if not and any other number if yes
*/
int StrList_isEqual(const StrList* StrList1, const StrList* StrList2);
/*
* Clones the given StrList.
* It's the user responsibility to free it with StrList_free.
*/
StrList* StrList_clone(const StrList* StrList);
/*
* Reverses the given StrList.
*/
void StrList_reverse( StrList* StrList);
/*
* Sort the given list in lexicographical order
*/
void StrList_sort( StrList* StrList);
/*
* Checks if the given list is sorted in lexicographical order
* returns 1 for sorted, 0 otherwise
*/
int StrList_isSorted(StrList* StrList);