What are data structures in dojox?

Data structures in dojox

The dojox provides six data structures modules:

  1. Stack

  2. Queue

  3. ArrayList

  4. Dictionary

  5. BinaryTree

  6. SortedList

Stack

The dojox.collections.Stack class implements a LIFO last-in first-out collection of objects. Here, the element that is inserted last will be removed first.

Queue

The dojox.collections.Stack class implements a FIFO First-in first-out collection of objects. Here, the element that is inserted first will be removed first.

ArrayList

The dojox.collections.ArrayList class is a resizable collection of elements. The ArrayList elements are accessed using an index. This class is similar to a JavaScript array.

Dictionary

The dojox.collections.Dictionary class is a collection of the key/value pairs. The key is used to lookup for the value.

SortedList

The dojox.collections.SortedList class is similar to a dictionary, but the key/value pairs are internally sorted. When a new element is added, the elements of the collection are forced to resort based on the inserted element.

BinaryTree

The dojox.collections.BinaryTree class stores data in a tree structure.

Code example

Let's look at the code below:

Console
Using stack

Code explanation

In the above code

  • Line 6: We load the dojo library from the CDN server.

  • Line 7: We load the dojox.collections.Stack module

  • Line 9: We create a new Stack object with name stack .

  • Lines 11 to 13: We use the push method to add three elements to the stack object.

  • Line 14: We use the toArray method to convert stack objects to an array and print the values present in the stack object.

  • Line 15: We use the count property to get the number of elements present in the stack.

  • Line 18: We use the pop method to remove and get the last inserted element.

  • Line 23: We use the clear method to remove all elements of the stack. After calling this method the stack becomes empty.


Note: To understand methods in each data structure, refer here.

Free Resources

Attributions:
  1. undefined by undefined
Copyright ©2025 Educative, Inc. All rights reserved