栈数据结构

A ds_stack is a last-in-first-out data structure.

A stack data structure is a so called last-in-first-out (LIFO) structure. You can push values onto a stack and the remove them again by popping them from the stack, and the value that was pushed on the stack most recently is the first to be popped from it again (just think of a stack of coins, where each coin that you add has to be removed again first before you can get to the rest of the coins beneath). Stacks are often used when there are interrupts to handle, or when having recursive functions, or even when constructing a rudimentary AI for your games.

NOTE: As with all dynamic resources, data structures take up memory and so should always be destroyed when no longer needed to prevent memory leaks which will slow down and eventually crash your game.

The following functions exist that deal with DS Stacks.

  1. ds_stack_create
  2. ds_stack_destroy
  3. ds_stack_clear
  4. ds_stack_empty
  5. ds_stack_size
  6. ds_stack_copy
  7. ds_stack_top
  8. ds_stack_pop
  9. ds_stack_push
  10. ds_stack_read
  11. ds_stack_write
注意:如果你需要检查数据结构是否存在,你可以使用ds_exists()函数。


上一页: Data Structures
下一页: Queues
© Copyright YoYo Games Ltd. 2018 All Rights Reserved