gm-docs-parser 1.0.0

A collection of typings for GameMaker Studio 2 manual pages
Documentation
<?xml version="1.0" encoding="utf-8" ?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>

  <script type="text/javascript" language="JavaScript">
    //<![CDATA[
    function reDo() {
      if (innerWidth != origWidth || innerHeight != origHeight)
        location.reload();
    }
    if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
      origWidth = innerWidth;
      origHeight = innerHeight;
      onresize = reDo;
    }
    onerror = null;
  //]]>
  </script>
  <style type="text/css">/*<![CDATA[*/

    < !-- div.WebHelpPopupMenu {
      position: absolute;
      left: 0px;
      top: 0px;
      z-index: 4;
      visibility: hidden;
    }

    p.WebHelpNavBar {
      text-align: right;
    }

    -->
  
/*]]>*/</style>

  <script type="text/javascript">//<![CDATA[

    gRootRelPath = "../../..";
    gCommonRootRelPath = "../../..";
    gTopicId = "9.2.8";
  
//]]></script>

  <script type="text/javascript" src="../../../template/scripts/rh.min.js"></script>
  <script type="text/javascript" src="../../../template/scripts/common.min.js"></script>
  <script type="text/javascript" src="../../../template/scripts/topic.min.js"></script>
  <script type="text/javascript" src="../../../template/scripts/topicwidgets.min.js"></script>
<script type="text/javascript" src="../../../whxdata/projectsettings.js"></script>
  <link rel="stylesheet" type="text/css" href="../../../template/styles/topic.min.css"/>
  <link rel="stylesheet" type="text/css" href="../../../template/Charcoal_Grey/topicheader.css"/>
  <meta name="topic-status" content="Draft"/>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>Data Structures</title>
  <meta name="generator" content="Adobe RoboHelp 2019"/>
  <link rel="stylesheet" href="../../../assets/css/default.css" type="text/css"/>
  <meta name="rh-authors" content="Mark Alexander"/>
  <meta name="topic-comment" content="Reference section for Data Structures"/>
  <meta name="rh-index-keywords" content=""/>
  <meta name="search-keywords" content="Data Structures"/>
</head>

<body>
  <div class="topic-header rh-hide" id="rh-topic-header" onclick="rh._.goToFullLayout()">
    <div class="logo">
    </div>
    <div class="nav">
      <div class="title" title="Data Structures">
        <span>Data Structures</span>
      </div>
      <div class="gotohome" title="Click here to see this page in full context">
        <span>Click here to see this page in full context</span>
      </div>
    </div>
  </div>
  <div class="topic-header-shadow rh-hide" id="rh-topic-header-shadow"></div>



  <!--<div class="body-scroll" style="top: 150px;">-->
  <h1>Data Structures</h1>
  <p>In games you often need to store information in a precise and ordered way. For example, you may need to store lists of items that a person carries or you may want to store a grid of places that still need to be visited. Now, you <i>can</i> use the arrays
    for this, but if you want to do more complicated operations, like sorting the data or searching for a particular item, you need to write large pieces of GML code which can be slow to execute, difficult to debug and a real pain to write!</p>
  <p>To remedy this, GameMaker Studio 2 has a number of built-in <b>data structures</b> that can be accessed through specialist functions. There are six different types of data structure available, each one having its own benefits depending on the
    type of information that you are looking to store and how you wish to manipulate it later: stacks, queues, lists, maps, priority queues, and grids.</p>
  <p>Essentially, all data structures work in the same way - You create a data structure and store its <i>index value</i> in a variable. You then use this index to reference the data structure in all further function calls that can perform operations on
    it. Finally, once you are done you destroy the data structure again to remove it from memory. You can use as many of the structures at the same time as you need, and all structures can store any of the available <a href="../../GML_Overview/Data_Types.htm">data types</a>.</p>
  <p class="note"><b>NOTE: </b>As with all dynamic resources, data structures take up memory and so should <b>always</b> be destroyed when no longer needed to prevent memory leaks which will slow down and eventually crash your game.</p>
  <p class="note"><b>IMPORTANT!</b> When you create a data structure, the index value to identify it is an integer value starting at 0. This means that different data structures can have the <b>same</b> index value, so if in doubt you should be using the <tt>ds_exists</tt>    function before accessing them. Also note that indices are re-used, so a destroyed data structure index value may be used by a newly created one afterwards, and we recommend that you set any variable that holds a DS index to -1 after having destroyed
    the data structure.</p>
  <p>Information on the different data structures can be found in the following sections:</p>
  <p> </p>
  <ul class="colour">
    <li><a href="DS_Grids/DS_Grids.htm">Grids</a></li>
    <li><a href="DS_Lists/DS_Lists.htm">Lists</a></li>
    <li><a href="DS_Maps/DS_Maps.htm">Maps</a></li>
    <li><a href="DS_Priority_Queues/DS_Priority_Queues.htm">Priority Queues</a></li>
    <li><a href="DS_Queues/DS_Queues.htm">Queues</a></li>
    <li><a href="DS_Stacks/DS_Stacks.htm">Stacks</a></li>
  </ul>
  <p> </p>
  <p>Before using data structures in your game, you should also be aware that there are certain moments when, due to rounding errors, you may get a result that is not what you expected. This may be resolved by changing the DS precision using the following
    function:</p>
  <p> </p>
  <ul class="colour">
    <li><a href="ds_set_precision.htm">ds_set_precision</a></li>
  </ul>
  <p> </p>
  <p>There is also a special function for checking to see whether a data structure of any given type exists:</p>
  <p> </p>
  <ul class="colour">
    <li><a href="ds_exists.htm">ds_exists</a></li>
  </ul>
  <p> </p>
  <p> </p>
  <p> </p>
  <div class="footer">
    <div class="buttons">
      <div class="clear">
        <div style="float:left">Back: <a href="../GML_Reference.htm">GML Reference</a></div>
        <div style="float:right">Next: <a href="../Strings/Strings.htm">Strings</a></div>
      </div>
    </div>
    <h5>© Copyright YoYo Games Ltd. 2020 All Rights Reserved</h5>
  </div>
  <!-- KEYWORDS
Data Structures
-->
  <!-- TAGS
data_structure_functions
-->

</body></html>