https://github.com/ruby0x1/structural
An unencumbered haxe data structures library
https://github.com/ruby0x1/structural
Last synced: about 1 month ago
JSON representation
An unencumbered haxe data structures library
- Host: GitHub
- URL: https://github.com/ruby0x1/structural
- Owner: ruby0x1
- License: mit
- Created: 2013-10-03T05:00:57.000Z (over 11 years ago)
- Default Branch: main
- Last Pushed: 2020-06-12T16:58:46.000Z (almost 5 years ago)
- Last Synced: 2025-01-29T09:45:07.585Z (3 months ago)
- Language: Haxe
- Size: 47.9 KB
- Stars: 21
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
structural
==========An unencumbered, generic haxe data structures library.
##Goals
- Single Structures without dependency on entire library
- Good coverage of generic data structures
- Based on common algorithms used in games and applications, found onlineMore tests and classes to come.
#Current Structures
- Bag
- Stack
- Pool
- Heap (third party)
- Binary Search Tree
- Balanced Binary Search Tree (Red/Black)
---
- Red/black self balancing Binary Search Tree ([read more](http://en.wikipedia.org/wiki/Self-balancing_binary_search_tree) and [read more](http://en.wikipedia.org/wiki/Red%E2%80%93black_tree))
```haxe
class Example {function compare( item1:Int, item2:Int ) {
if(item1 == item2) return 0;
if(item1 < item2) return -1;
return 1;
}function explain() {
var tree = new BalancedBST( compare );
tree.insert( 3, new SomeValue() );for(some_value_instance in tree) {
//use instance
}
}
}
```- Unbalanced Binary Search Tree ([read more](http://en.wikipedia.org/wiki/Binary_search_tree))
```haxe
class Example {function compare( item1:Int, item2:Int ) {
if(item1 == item2) return 0;
if(item1 < item2) return -1;
return 1;
}function explain() {
var tree = new BST( compare );
tree.insert( 3, new SomeValue() );for(some_value_instance in tree) {
//use instance
}
}
}
```- Stack ([read more](http://en.wikipedia.org/wiki/Stack_(abstract_data_type)))
```haxe
class Example {
function explain() {
var stack = new Stack();
stack.push( 'item1' );
stack.push( 'item2' );
stack.push( 'item3' );for(item in stack) {
trace('string is : ' + item );
}
}
}
```- Bag ([read more](http://en.wikipedia.org/wiki/Multiset))
```haxe
class Example {
function example() {
var bag = new Bag();
bag.add( 'item1' );
bag.add( 'item2' );
bag.add( 'item3' );for(item in bag) {
trace('string is : ' + item );
}
}
}
```- Pool ([read more](http://en.wikipedia.org/wiki/Pooling_(resource_management)))
```haxe
class Example {
function example() {var pool = new Pool(20, create_sprite, false);
//to use the next pooled item,
//looping around to index 0 when end of pool is reached.
var next = pool.get();}
function create_sprite(index:Int, total:Int) {
//generate a new instance,
//called a maximum of `total` times (from pool size)
return new Sprite();
}}
```MIT License (see LICENSE.md file for more details)