Download and put panda.c and panda.h in the Floder which your program at
include "panda.h" in your program gcc panda.c yourfile -o filename
define the struct
Vector(dataType, structName);
declare the vector
structName* vectorName = create_vector_structName();
Inserts elements at the specified location in the container.
vectorName->insert(vectorName, index, element);
Erases the specified elements from the container.
vectorName->remove(vectorName, index);
Replaces the contents of the container.
vectorName->set(vectorName, index, element);
Returns a reference to the element at specified location pos. No bounds checking is performed.
vectorName->get(vectorName, index);
Appends the given element value to the end of the container.
vectorName->push(vectorName, element);
Removes the last element of the container.
vectorName->pop(vectorName);
Returns a reference to the last element in the container.
vectorName->back(vectorName);
Returns a reference to the first element in the container.
vectorName->front(vectorName);
Erases all elements from the container. After this call, size is zero.
vectorName->clear(vectorName);
free the container
vectorName->free(vectorName);
reset the capacity of the container
vectorName->free(vectorName, newSize);
Checks if the container has no elements
vectorName->empty(vectorName);
Exchanges the contents of the container with those of other
vectorName->swap(vectorName, index1, index2);
sort the container
vectorName->sort(vectorName, compareFunction);
Returns the number of elements in the container
vectorName->size;
define the struct
List(dataType, structName);
declare the list
structName* listName = create_list_structName();
Inserts elements at the specified location in the container.
listName->insert(*index, element);
Erases the specified elements from the container.
listName->remove(*index);
Replaces the contents of the container.
listName->set(*index, element);
Returns a reference to the element at specified location pos. No bounds checking is performed.
listName->get(*index);
Appends the given element value to the end of the container.
listName->push_back(listName, element);
Appends the given element value to the first of the container.
listName->push_back(listName, element);
Removes the last element of the container.
listName->pop_back(listName);
Removes the first element of the container.
listName->pop_front(listName);
Returns a reference to the last element in the container.
listName->back(listName);
Returns a reference to the first element in the container.
listName->front(listName);
Erases all elements from the container. After this call, size is zero.
listName->clear(listName);
free the container
listName->free(listName);
Checks if the container has no elements
listName->empty(listName);
Exchanges the contents of the container with those of other
listName->swap(listName, index1, index2);
sort the container
listName->sort(listName, compareFunction);
Returns the number of elements in the container
listName->size;
define the struct
Stack(dataType, structName);
declare the stack
structName* stackName = create_stack_structName();
Appends the given element value to the end of the container.
stackName->push(stackName, element);
Removes the last element of the container.
stackName->pop(stackName);
Returns a reference to the last element in the container.
stackName->top(stackName);
Erases all elements from the container. After this call, size is zero.
stackName->clear(stackName);
free the container
stackName->free(stackName);
Checks if the container has no elements
stackName->empty(stackName);
Returns the number of elements in the container
stackName->size;
define the struct
Queue(dataType, structName);
declare the queue
structName* queueName = create_queue_structName();
Appends the given element value to the end of the container.
queueName->push(queueName, element);
Removes the first element of the container.
queueName->pop(queueName);
Returns a reference to the first element in the container.
queueName->front(queueName);
Returns a reference to the last element in the container.
queueName->front(queueName);
Erases all elements from the container. After this call, size is zero.
queueName->clear(queueName);
free the container
queueName->free(queueName);
Checks if the container has no elements
queueName->empty(queueName);
Returns the number of elements in the container
queueName->size;
define the struct
Priority_Queue(dataType, structName, compareFunctionofData);
declare the priorityqueue
structName* priorityqueueName = create_priority_queue_structName();
compare function
bool compare(type A, type B);
if A have higher priority return 1, else return 0
Inserts a new element in the priority_queue. The content of this new element is initialized to val.
priorityqueueName->push(priorityqueueName, element);
Removes the top element of the container.
priorityqueueName->pop(priorityqueueName);
Returns a reference to the first element in the container.
priorityqueueName->front(priorityqueueName);
Erases all elements from the container. After this call, size is zero.
priorityqueueName->clear(priorityqueueName);
free the container
priorityqueueName->free(priorityqueueName);
Checks if the container has no elements
priorityqueueName->empty(priorityqueueName);
Returns the number of elements in the container
priorityqueueName->size;
define the struct
Set(dataType, structName, compareFunctionofData);
declare the set
structName* setName = create_set_structName();
compare function
int compare(type A, type B);
- A>B return 1
- A==B return 0
- A<B return -1
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
setName->insert(setName, key);
Removes specified elements from the container.
setName->remove(setName, key);
Returns the number of elements with key that compares equivalent to the specified argument.
setName->count(setName, key);
Erases all elements from the container. After this call, size is zero.
setName->clear(setName);
free the container
setName->free(setName);
Checks if the container has no elements
setName->empty(setName);
Returns an iterator pointing to the first element that is not less than key
setName->lowerbound(setName, key, compareFunction);
Returns an iterator pointing to the first element that is greater than key
setName->upperbound(setName, key, compareFunction);
Returns the number of elements in the container
setName->size;
define the struct
Map(indexType, valueType, structName, compareFunctionofData);
declare the map
structName* mapName = create_map_structName();
compare function
bool compare(indexType A, indexType B);
- A>B return 1
- A==B return 0
- A<B return -1
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
mapName->insert(mapName, key);
Removes specified elements from the container.
mapName->remove(mapName, key);
Returns the number of elements with key that compares equivalent to the specified argument.
mapName->count(mapName, key);
Returns the elements with key that compares equivalent to the specified argument.
mapName->val(mapName, key);
Replaces the contents of the container.
mapName->set(mapName, index, element);
Erases all elements from the container. After this call, size is zero.
mapName->clear(mapName);
free the container
mapName->free(mapName);
Checks if the container has no elements
mapName->empty(mapName);
Returns an iterator pointing to the first element that is not less than key
mapName->lowerbound(mapName, key, compareFunction);
Returns an iterator pointing to the first element that is greater than key
mapName->upperbound(mapName, key, compareFunction);
Returns the number of elements in the container
mapName->size;
define the struct
Treap(dataType, structName, compareFunctionofData, pullUpFunctionofData, pushDownFunctionofData);
declare the treap
structName* treapName = create_treap_structName();
compare function
bool compare(dataType A, dataType B);
if A have higher priority return 1, else return 0
pullUP function
void pullup(data *A, data *AleftNode, data *ArightNode);
update A from its children
ex: interval sum
void pullUp(data* A, data* AleftNode, data* ArightNode) {
A->size = 1;
A->sum = a->val;
if (AleftNode != nullptr) A->size += AleftNode->size;
if (ArightNode != nullptr) A->size += ArightNode->size;
if (AleftNode != nullptr) {
A->sum += (AleftNode->sum);
if (AleftNode->tag) {
A->sum += (AleftNode->tag) * (AleftNode->size);
}
}
if (ArightNode != nullptr) {
A->sum += (ArightNode->sum);
if (ArightNode->tag) {
A->sum += (ArightNode->tag) * (ArightNode->size);
}
}
return;
}
pushDown function
void pushDown(data *A, data *AleftNode, data *ArightNode);
A is updated, push the data down to its children
ex: lazytag of interval sum
void pushDown(data* A, data* AleftNode, data* ArightNode) {
if (A->tag) {
A->sum += (A->tag) * (A->size);
A->val += (A->tag);
if (AleftNode != nullptr) AleftNode->tag += (A->tag);
if (ArightNode != nullptr) ArightNode->tag += (A->tag);
A->tag = 0;
}
return;
}
node_structName:
- data treeKey
- node_structName* leftNode, *RightNode
- int heapkey
Return a node pointer point to a new node of treap
node_structName* nodeName = treapName->build(treapName, data);
Return a node pointer point a new root of treap that merge two given treap
node_structName* newRoot = treapName->merge(treapName, treapA, treapB);
warning
treapA and treapB is node_structName*
split a treap to two treap by key that you give
treapName->split(treapName, originalTreapRoot, key, newTreapRootA, newTreapRootB);
warning
newTreapRootA and newTreapRootB is *node_structName's address
ex:
node_structName *newNodeA, *newNodeB
treap->split(treap, treap->treap, key, &newNodeA, &newNodeB)
free the container
treapName->free(treapName);
Returns an iterator pointing to the first element in the range [first,last) which does not compare less than v. The elements in the range shall already be sorted according to this same criterion
Returns an iterator pointing to the first element in the range [first,last) which does compare greater than v. The elements in the range shall already be sorted according to this same criterion
Sorts the elements in the range [first, last) in non-descending order with cmp.
Exchanges the given values.
Returns the greater of the given values.
Returns the smaller of the given values.
(void*)0