Go to content

Main menu:

The Fundamentals of the List Object

Last Updated: January 17th, 2016
MMFusion provides all sorts of tools for data storage. Previously, we've already partially discussed arrays and INIs in the Basics of Saving Data in Multimedia Fusion and Clickteam Fusion tutorial. This covers another data storage extension; the List Object. This tutorial covers the concept, purposes, basic capabilities, and example uses of the List Object.

Quick Links:
What is a List?
The List Object creates and stores lists, a type of data structure. As mentioned in the Basics of Saving Data in MMFusion tutorial, lists can be thought as special cases of 1D (one dimensional) arrays. Whereas arrays store data in each array slot (index), lists store data in each line. Below is a partial list describing some additional differences between lists and 1D arrays:

  1. Arrays typically have fixed (static) sizes while lists typically have variable (dynamic) sizes. This means that after creation, the size of arrays remains unchanged over time while the size of lists may fluctuate over time. This results from how the list data structure works, described here. Depending on your needs, you may need to switch between arrays and lists.
  2. Array elements are stored in contiguous blocks of memory while list elements are stored in anywhere in memory. Because of this, accessing the nth element in a list typically requires you to visit every element before it resulting in slower access times per data element.
  3. List are significantly better at reordering its internal data than arrays. That being said, there are many sorting algorithms, each of which are catered to either arrays or lists.

As a MMFusion user, most of the differences between arrays and lists will not matter unless you plan to store thousands of data elements or create your own data structure extension. Nonetheless, learning these differences allows you to make the most of MMFusion!
Why Use Lists?
Like other data structures, lists store data. In MMFusion, the List Object stores numeric data or text datasimilar to the Array Object. Numeric data is (only) stored in a list element's "list data" while text data is stored within an actual list element. The Windows Control component of the List object shows this text data. When lines are inserted, you specify the initial text data. As such, newly inserted lines default to a list data of 0. You must manually modify a list element's numeric data after the list element is inserted into the list. 

Given the capabilities of arrays, why should we consider using lists? Below are a few explicit reasons recommending lists (the List Object) over arrays (the Array Object):
  • In MMFusion, visible List Objects are shown onscreen in the application as Window Controls. As such, you can easily see the contents of the list. For arrays, you need to iterate through the array, pull data from the array, and output the results to another object.
  • List element manipulation is easier and more versatile than array element manipulation. For example, removing list elements is as simple as executing the "Delete a line" action. Since arrays are designed with fixed sizes, there is no explicit method to remove or delete array elements.
  • The List Object can implement automatic basic sorting on its elements, thusly providing easier organization of its elements. Any array sorting algorithm would need to be custom developed.
The List Object: A Windows Control Object
When visible, the List Object displays its contents in a Windows Control. You, the developer, can exploit this property to create message logs (such as the example chat room log below), custom debuggers, and other related structures. Visible lists, however, can degrade performance since they show as Windows Controls. As such, you can increase performance by making these lists invisible during runtime. 

An example image where the List Object is used as a message log
List's Sorting Capabilities
The List Object has a property (the "Sort" checkbox) which sorts its list elements in alphanumerical order. When enabled, inserted elements are automatically sorted to their proper locations. This property can be changed during runtime providing a flexible way to manipulate the list.
How the List Object Works
There are three basic operations for the List Object; element insertion, modification, and deletion. These three operations provide almost full control over a given List Object. These operations are as follows:

Use one of these actions to insert elements into a List Object:
  • Insert a new line (inserts a line element at a specified index)
  • Add a new line (adds a line element to the end of the list)

Use one of these actions to modify elements in a List Object:
  • Change a line (changes the text data of a line element)
  • Set line data (changes the numeric data of a line element)

Use one of these actions to delete elements from a List Object:
  • Delete a line (deletes a line element with a specified index)
  • Reset list (delete all line elements in the list)

There three operations are the primary ways you, the developer, interact with the List Object. You add new elements, change existing elements, and remove existing elements. In addition to these three operation, you can manipulate several visual-based variables, such as font size and color, of the List Object when the object is visible. These variables can be modified as needed during edittime and runtime.
This image shows the Sort checkbox under the Settings of the List Object
This image shows the "Sort" checkbox property of the List Object.
Example and Practical Uses of the List Object
Some example uses of the List Object include the ability to:
  • Develop an alternative method of Creating Random Pools in MMFusion. You can add numbers to the list and remove these numbers after they are picked.
  • Sort data quickly and easily. You can alphabetically sort the contents of the list. Extremely useful for sorting arrays.
  • Utilize stack and/or queue data structures. You can manipulate the ordering of the list to benefit your needs.
  • Create a log of events/messages. Assuming messages are always added to the end of the list, you can get a basic timeline of occurring events, like the example message log shown above.
Summary
Below is a bulleted summary of the above tutorial:
  • Lists are conceptually similar to one dimensional (1Darrays.
  • Lists can store numeric and text data
  • Lists can insert and delete items more efficiently than arrays
  • Lists are useful represent or store data where order is important
  • The List Object can perform automatic sorting on its data elements

In conclusion, lists are another useful tool in MMFusion development. Many concepts and ideas are expressed easier with lists than arrays. To maximize the utility of lists however, you'll also need to learn about iteration and loops. Check out the example files linked in this tutorial's "Downloads" section for implementation and application of lists and the List Object.

Rate This Tutorial
Vote: 4.1/5
If you have read this tutorial, rate it from poor (1) to average (3) to great (5)!
Back to content | Back to main menu