PHP Classes

Abstract Data Types: Set of abstract data types as pure PHP classes

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 241 All time: 8,024 This week: 36Up
Version License PHP version Categories
falcraftdatatypes 1.0MIT/X Consortium ...5.3PHP 5, Libraries, Data types
Description 

Author

This package implements a set of abstract data types as pure PHP classes.

It provides many classes that implement algorithms or act as containers to manage sets of values. Currently it implements the following data types:

- Restrictions (An OOP Typing Predicate)
- Graphs and vertex or edge nodes
- Stacks, Queues, Lists
- TaggedUnion, Structure
- Map (Object Keys and Values)

Picture of Asher Wolfstein
  Performance   Level  
Name: Asher Wolfstein <contact>
Classes: 15 packages by
Country: United States United States
Age: 41
All time rank: 1121164 in United States United States
Week rank: 180 Up22 in United States United States Up
Innovation award
Innovation award
Nominee: 5x

Example

<?php

/* SOME TESTS ARE MEANT TO FAIL!
   If the entire script runs, it works. */

require_once('../../../Data/Types/Leaf.php');

use
Falcraft\Data\Types;

echo
"Falcraft\\Data\\Types\\Leaf.php Test\n";
echo
"---------------------------------\n\n";

echo
"Instantiation -- \n";

echo
" Basic Empty -> ";

$success = true;

$testLeaf = null;

try {
   
$testLeaf = new Types\Leaf();
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
" Instantiation With Improper Values -> ";

$fail = true;

$testLeaf = $testArray = null;

try {
   
$testArray = array(5, 'notLeaf', 'what?' => 'delicious',);
   
$testLeaf = new Types\Leaf($testArray);
   
$fail = false;
} catch (\
Exception $e) {
   
}

if (
$fail) {
    echo
"Failure!\n";
} else {
    echo
"Success...\n";
}

echo
" Instantiation With Proper Values -> ";

$success = true;

$testLeaf = $testArray = null;

try {
   
$testArray = array(new Types\Leaf(), new Types\Leaf(), new Types\Leaf());
   
$testLeaf = new Types\Leaf($testArray);
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"\nReset\n";
echo
"-----\n\n";

unset(
$testLeaf);
unset(
$testArray);

echo
"New Leaf -> ";

$success = true;

$testLeaf = null;
$testIdentifier = null;

try {
   
$testLeaf = new Types\Leaf();
   
$testIdentifier = $testLeaf->getIdentifier();
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success! Identifier: $testIdentifier\n";
} else {
    echo
"Failure...\n";
}

echo
"Altering Leaf Prefix (root) and adding -> ";

$success = true;

$testLeaf1 = $testIdentifier1 = null;
$testLeaf2 = $testIdentifier2 = null;
$testIdentifier3 = null;

try {
   
$testLeaf1 = new Types\Leaf();
   
$testIdentifier1 = $testLeaf->getIdentifier();
   
$testLeaf2 = new Types\Leaf(array(), array('prefix' => 'Root',));
   
$testIdentifier2 = $testLeaf2->getIdentifier();
   
$testIdentifier3 = $testLeaf1->addLeaf($testLeaf2);
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
    echo
" identifier1: $testIdentifier1\n";
    echo
" identifier2: $testIdentifier2\n";
    echo
" identifier3: $testIdentifier3\n";
} else {
    echo
"Failure...\n";
}

echo
"Did $identifier3 Generate? ";

$success = false;

try {
   
$success = $testLeaf1->isLeaf($identifier3);
} catch (\
Exception $e) {
   
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"Data Setting and Retrieval -> ";

$d = 5;

try {
   
$testLeaf1->setData($d);
   
$d = 10;
   
$d = $testLeaf1->getData();
} catch (\
Exception $e) {
   
$d = 0;
}

if (
$d == 5) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}



  Files folder image Files (72)  
File Role Description
Files folder imageFalcraft (1 file, 4 directories)

  Files folder image Files (72)  /  Falcraft  
File Role Description
Files folder imageData (1 directory)
Files folder imageexamples (1 directory)
Files folder imageFeatures (1 file)
Files folder imageResource (1 file)
  Accessible without login Plain text file falcraftLoad.php Aux. File Loader

  Files folder image Files (72)  /  Falcraft  /  Data  
File Role Description
Files folder imageTypes (24 files, 2 directories)

  Files folder image Files (72)  /  Falcraft  /  Data  /  Types  
File Role Description
Files folder imageException (7 files)
Files folder imageResource (15 files)
  Plain text file Edge.php Class An Edge Object (Graphs)
  Plain text file Enumeration.php Class Enum Data Type
  Plain text file Leaf.php Class Leaf Object (Trees)
  Plain text file LexicographicList.php Class Alphabetical List
  Plain text file Map.php Class Map (Object to Object Array)
  Plain text file Null.php Class Null Object
  Plain text file OrderedEdge.php Class Placed Edge Implementation (Graphs)
  Plain text file OrderedNode.php Class Placed Node (Graphs)
  Plain text file Priority.php Class Priority for PriorityQueue
  Plain text file PriorityQueue.php Class Priority Queue Implementation
  Plain text file Queue.php Class Queue Implementation
  Plain text file Range.php Class Range Predicate Object
  Plain text file RestrictedList.php Class List Implementation
  Plain text file RestrictedQueue.php Class Queue Implementation
  Plain text file RestrictedSet.php Class Set Implementation
  Plain text file RestrictedStack.php Class Stack Implementation
  Plain text file Restrictions.php Class Type Classifying Predicate Object
  Plain text file Set.php Class Set Implementation
  Plain text file Stack.php Class Stack Implementation
  Plain text file Structure.php Class Structure Implementation
  Plain text file TaggedUnion.php Class Tagged Union Implementation
  Plain text file Type.php Class Type Classifying
  Plain text file UnorderedNode.php Class Floating Node (Graphs)
  Plain text file VertexList.php Class Ordered List of Vertexes

  Files folder image Files (72)  /  Falcraft  /  Data  /  Types  /  Exception  
File Role Description
  Plain text file BadMethodCallException.php Class Bad Method Call Error
  Plain text file CodeGenerationException.php Class Code Generation Error
  Plain text file ExceptionInterface.php Class Local Exception Interface
  Plain text file InvalidArgumentException.php Class Invalid Argument Error
  Plain text file RangeException.php Class Range Error
  Plain text file RuntimeException.php Class Runtime Error
  Plain text file UnexpectedValueException.php Class Unexpected Value Error

  Files folder image Files (72)  /  Falcraft  /  Data  /  Types  /  Resource  
File Role Description
  Plain text file AbstractFilter.php Class Abstract Filter Class
  Plain text file AbstractLeaf.php Class Abstract Leaf Class
  Plain text file AbstractLinkedListElement.php Class Abstract Element Class
  Plain text file AbstractList.php Class Abstract List Class
  Plain text file AbstractRestrictedList.php Class Abstract Restricted List Class
  Plain text file AbstractSortedList.php Class Abstract Sorted List Class
  Plain text file AbstractVertex.php Class Vertex Abstract Class (Graphs)
  Plain text file EdgeInterface.php Class Edge Object Interface (Graphs)
  Plain text file FilterInterface.php Class Filter Object Interface
  Plain text file LeafInterface.php Class Leaf Object Interface
  Plain text file LinkedListElementInterface.php Class Element Object Interface
  Plain text file ListInterface.php Class List Object Interface
  Plain text file PriorityInterface.php Class Priority Object Interface
  Plain text file SetInterface.php Class Set Object Interface
  Plain text file VertexInterface.php Class Vertex Object Interface

  Files folder image Files (72)  /  Falcraft  /  examples  
File Role Description
Files folder imageData (1 directory)

  Files folder image Files (72)  /  Falcraft  /  examples  /  Data  
File Role Description
Files folder imageTypes (23 files)

  Files folder image Files (72)  /  Falcraft  /  examples  /  Data  /  Types  
File Role Description
  Accessible without login Plain text file Edge.php Example Edge Object (Graphs) Example
  Accessible without login Plain text file Enumeration.php Example Enum Data Type Example
  Accessible without login Plain text file Leaf.php Example Leaf (Tree) Example
  Accessible without login Plain text file LexicographicList.php Example Alphabetic List Example
  Accessible without login Plain text file Map.php Example Map (Object Keys) Example
  Accessible without login Plain text file Null.php Example Null Object Test
  Accessible without login Plain text file OrderedEdge.php Example Placed Edge (Graphs) Example
  Accessible without login Plain text file OrderedNode.php Example Placed Node (Graphs) Example
  Accessible without login Plain text file Priority.php Example Priority (For PriorityQueue) Example
  Accessible without login Plain text file PriorityQueue.php Example Queue Example
  Accessible without login Plain text file Queue.php Example Queue Example
  Accessible without login Plain text file Range.php Example Range Example
  Accessible without login Plain text file RestrictedQueue.php Example Queue Example
  Accessible without login Plain text file RestrictedSet.php Example Set Example
  Accessible without login Plain text file RestrictedStack.php Example Stack Example
  Accessible without login Plain text file Restrictions.php Example Type Restrictions Predicate Example
  Accessible without login Plain text file Set.php Example Set Example
  Accessible without login Plain text file Stack.php Example Stack Example
  Accessible without login Plain text file Structure.php Example Structure Example
  Accessible without login Plain text file TaggedUnion.php Example Tagged Union Example
  Accessible without login Plain text file Type.php Example Type Classifications Example
  Accessible without login Plain text file UnorderedNode.php Example Unorderd Node Examples
  Accessible without login Plain text file VertexList.php Example Vertex List Examples

  Files folder image Files (72)  /  Falcraft  /  Features  
File Role Description
  Plain text file Identity.php Class An Identitification Generator

  Files folder image Files (72)  /  Falcraft  /  Resource  
File Role Description
  Accessible without login Plain text file ArrayUtilities.php Aux. Some Utility Functions

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
Downloadfalcraftdatatypes-2015-10-06.zip 142KB
Downloadfalcraftdatatypes-2015-10-06.tar.gz 89KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
PHP Enum Data Type Download .zip .tar.gz Types and Restrictions Use This, Included in Package Optional
PHP Configuration Trait Download .zip .tar.gz Data Type Objects Use This For Configuration Required
 Version Control Reuses Unique User Downloads Download Rankings  
 0%3
Total:241
This week:0
All time:8,024
This week:36Up