#232

Product support

Get help in the plugin support forum.

Categories

  • Developer Tools

Useful for more complex data manipulation and rendering.

Overview

This plugin provides data structure implementations which are useful for everyday programming tasks. The game plan is to eventually add components for displaying contents of the data structures directly as well as for generating data structures from form data. However, these structures can be used directly programmatically when building your own plugins.

If you find any bugs or problems in any of my data structures, please let me know. Thanks.

Structures

  • Grid
  • List
  • Enum (In Progress)

Planned Structures

  • Tree
  • Heap
  • Structure
  • Stack
  • Queue

Grid

Creates a grid like data structure, useful for transitioning data to an UI.

Features
  • Takes in a 1-dimensional collection and is able to automatically format it into a grid of items.
  • Can automatically output sizings for creating row and columns with CSS libraries like Bootstrap and Material CSS.
Planned
  • Abstract the sizing further to allow compatbility with more grid CSS libraries

List

Creates a list of data useful for data manipulation.

Features
  • Expands upon the existing OctoberCMS collection
  • Allows for a limit to the list
  • Create the ability to drop the first entered items if the list exceeds its capacity on a list.push operation
  • Intelligent merging
Planned
  • Create a core for the stack and queue data structures to build off (Extends).

Enum

Useful to abstract away state based String comparisons

Features
  • Enum

Tree

The tree data structure will be useful for searching, sorting, heaps, and organization.

Planned
  • B-tree
  • B-search tree
  • Tree
  • AVL Tree
  • Expression Tree

Heap

The heap is used for efficient finding min, maxes, and sorting.

Planned
  • Min/Max heap
  • Min heap
  • Max heap
  • Heap sorting

Structure

A play off of C++ structures. Allows for creation of a data structure with X fields.

Planned
  • Basic structures. Think of models without the need for a database

Stack

Great for parsing and reversing orders

Planned
  • Stack

Queue

An expanded List data structure. Tailored to maintain order.

Planned
  • Queue
  • Priority queue

Installation

  1. Install the Clake.DataStructutres plugin.
  2. You're done :)

Usage

Include the class file for the data structure you would like to use. So far, you can use the Enum, Grid, and Lists data structures. A detailed description of what these do can be found on the overview page.

Grid

First initialize the grid with some properties. Then, call the gridify method and pass it some data. From there you can retrieve rows of data, specific row&cols of data and automatically calculated responsive CSS style sizings.

This will create a grid with 3 columns and as many rows as it needs to fit all the data. Then, it will split $data up into each slot in the grid from left to right, top to bottom.

$grid = Grid::init(3, 0)->gridify($data);

This will get the piece of data in row 2 and column 3.

$piece = $grid->getIndex(3, 2);

This will return an array of responsive CSS style measurements for small, medium, and large screens. Useful for libraries like Bootstrap and MaterialCSS.

$style = $grid->getAllColStyleSize();
<div class="col-sm-$style['s'] col-md-$style['m'] col-lg-$style['l']">Column 1</div>
<div class="col-sm-$style['s'] col-md-$style['m'] col-lg-$style['l']">Column 2</div>
<div class="col-sm-$style['s'] col-md-$style['m'] col-lg-$style['l']">Column 3</div>

Lists

First, create a new list and pass it some data.

$list = new List($data);
$list2 = List::create($data);

Enable/Disable automatic list size limiting. This if off by default.

$list->enableLimiting(15);
$list->disableLimiting();

Set the limit of the list. This will also turn on limiting.

$list2->setLimit(10);

Push more data onto the list. This will chop off the first in data to the list if limiting is turned on.

$list2->pushList($moreData);

Retrieve the list. Limits the list if limiting is turned on.

$list->getList();

Get the whole list regardless of limiting.

$list->allList();

Enum

You MUST extend the Enum class to create an Enum.

class eAppStates extends Clake\DataStructures\Classes\Enum
{
    $enum = ["LOADING", "STARTING", "EXITING"];
}

Create an Enum instance

$appState = eAppStates::LOADING();

Change what the Enum instance is set as and returns the Enum instance

$appState(STARTING);
$appState->LOADING;

Compares two Enums for equality

$appState2 = eAppState::LOADING();
if($appState->compare($appState2))
    echo "The app states are equal";
1.0.1

First version of DataStructures

Dec 15, 2016