70 lines
2.5 KiB
HTML
70 lines
2.5 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<title>Stacks</title>
|
|
<link href="style.css" rel="stylesheet" type="text/css">
|
|
</head>
|
|
<body background="images/back.gif">
|
|
<!--START-->
|
|
|
|
<h3>Stacks</h3>
|
|
|
|
A stack data structure is a so called LIFO (Last-In First-Out) structures. You can
|
|
push values on a stack and the remove them again by popping them from the stack.
|
|
The value that was pushed on the stack most recently is the first to be popped
|
|
from it again. Stacks are often used when there are interrupts to handle, or
|
|
when having recursive functions. The following functions exist for stacks:
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>ds_stack_create()</b></tt>
|
|
Creates a new stack. The function returns an integer as an id
|
|
that must be used in all other functions to access the particular
|
|
stack. You can create multiple stacks.<br>
|
|
<tt><b>ds_stack_destroy(id)</b></tt>
|
|
Destroys the stack with the given id, freeing the memory used. Don't
|
|
forget to call this function when you are ready with the structure.<br>
|
|
<tt><b>ds_stack_clear(id)</b></tt>
|
|
Clears the stack with the given id, removing all data from it but
|
|
not destroying it.<br>
|
|
<tt><b>ds_stack_copy(id,source)</b></tt>
|
|
Copies the stack source into the stack with the given id.<br>
|
|
<tt><b>ds_stack_size(id)</b></tt>
|
|
Returns the number of values stored in the stack.<br>
|
|
<tt><b>ds_stack_empty(id)</b></tt>
|
|
Returns whether the stack is empty. This is the same as testing whether the size is 0.<br>
|
|
<tt><b>ds_stack_push(id,val)</b></tt>
|
|
Pushes the value on the stack.<br>
|
|
<tt><b>ds_stack_pop(id)</b></tt>
|
|
Returns the value on the top of the stack and removes it from the stack.<br>
|
|
<tt><b>ds_stack_top(id)</b></tt>
|
|
Returns the value on the top of the stack but does not remove it from the stack.<br>
|
|
<tt><b>ds_stack_write(id)</b></tt>
|
|
Turns the data structure into a string and returns this string. The string can then
|
|
be used to e.g. save it to a file. This provides an easy mechanism for saving data
|
|
structures.<br>
|
|
<tt><b>ds_stack_read(id,str)</b></tt>
|
|
Reads the data structure from the given string (as created by the previous call).<br>
|
|
</blockquote>
|
|
|
|
<!--END-->
|
|
</body>
|
|
</html>
|
|
|
|
<!-- KEYWORDS
|
|
stacks
|
|
|
|
ds_stack_create()
|
|
ds_stack_destroy()
|
|
ds_stack_clear()
|
|
ds_stack_copy()
|
|
ds_stack_size()
|
|
ds_stack_empty()
|
|
ds_stack_push()
|
|
ds_stack_pop()
|
|
ds_stack_top()
|
|
ds_stack_write()
|
|
ds_stack_read()
|
|
|
|
--> |