PBXB64 H-Lib Containers

Complete Native H-Lib Collection PBXB64 V21

PBXB64 V21 integrates 22 core H-Lib families plus the Safe synchronized wrapper as first-class managed data types with more than 125 typed variants. The range covers Arr, Stk, Que, Lst, Str, 2D, Hsh, Tre, DTre, Tri, Heap, Deque, Set, Graph, Multiset, Union-Find, LRU Cache, Ring, SkipList, B+ Tree, Quadtree, Bloom Filter, and Safe structures. They use dot-method syntax, require no external library, and clean up automatically at scope exit.

The sections below show representative collection patterns. The data-type reference explains family names, PB value prefixes, and managed lifetime behavior.

Hash Table (SSSHSH) - Associative Key-Value Storage

Hash-based associative container with string keys and string values. O(1) average lookup. Full CRUD operations.

SSSHSH - Key-value storage
#COMPILE EXE #DIM ALL FUNCTION PBMAIN() AS LONG LOCAL person AS SSSHSH ' hash table: STRING key -> STRING value person = person.New person.Put "name", "Alice" person.Put "age", "30" person.Put "city", "Berlin" PRINT "Name: "; person.Get("name") PRINT "Age: "; person.Get("age") PRINT "Zip: "; person.TryGet("zip", "(none)") ' default for a missing key person.Remove "age" PRINT "Has age:"; person.Contains("age") ' 0 PRINT "Count: "; person.Count ' 2 person.Final ' release (also automatic at scope exit) FUNCTION = 0 END FUNCTION

SSSHSH API (string key to string value): .Put, .Get, .TryGet, .Contains, .Remove, .Count, .Clear, .Keys, .Values, .Final. Declare with LOCAL x AS SSSHSH and create the table with x = x.New.

LNARR - Dynamic Array

Dynamic array with automatic resize. O(1) amortized append.

LNARR - Dynamic array
#COMPILE EXE #DIM ALL FUNCTION PBMAIN() AS LONG LOCAL v AS LNARR ' growable array of 64-bit integers LOCAL i AS LONG LOCAL n AS QUAD v = v.New v.Push 30 v.Push 10 v.Push 20 PRINT "Count: "; v.Count ' 3 PRINT "Item 1: "; v.Get(1) ' PB index is 1-based -> 30 v.Set 2, 15 ' overwrite item 2 v.Ins 1, 99 ' insert 99 at index 1 v.Del 1 ' delete it again v.Sort ' ascending order FOR EACH n IN v PRINT n; NEXT PRINT PRINT "Popped: "; v.Pop ' last element (30) v.Final FUNCTION = 0 END FUNCTION

LNARR API (array of 64-bit integers): .Push, .Add, .Pop, .Peek, .Get, .Set, .Ins, .Del, .Count, .IndexOf, .Contains, .Sort, .SortDesc, .Reverse, .Clear, plus FOR EACH. Indices are 1-based, as in PowerBASIC.

AVL Tree (LNLNTRE) - Balanced Binary Search

Self-balancing (AVL) binary search tree. O(log n) insert, delete, find.

LNLNTRE - Ordered key-value tree
#COMPILE EXE #DIM ALL FUNCTION PBMAIN() AS LONG LOCAL t AS LNLNTRE ' ordered tree: LONG key -> LONG value t = t.New t.Put 50, 500 t.Put 30, 300 t.Put 70, 700 t.Put 20, 200 t.Put 40, 400 PRINT "Contains 30: "; t.Contains(30) ' non-zero PRINT "Min: "; t.Min ' 20 PRINT "Max: "; t.Max ' 70 PRINT "Floor(35): "; t.Floor(35) ' 30 PRINT "Ceil(35): "; t.Ceil(35) ' 40 t.Remove 30 PRINT "Contains 30: "; t.Contains(30) ' 0 PRINT "Count: "; t.Count ' 4 t.Final FUNCTION = 0 END FUNCTION

LNLNTRE API (LONG key to LONG value, kept in key order): .Put, .Get, .TryGet, .Remove, .Contains, .Min, .Max, .Floor, .Ceil, .Keys, .Values, .Count, .Clear.

Linked List - LIFO / FIFO

Doubly-linked list with O(1) push/pop at both ends.

Linked List - Queue / Stack
#COMPILE EXE #DIM ALL FUNCTION PBMAIN() AS LONG LOCAL lst AS LNLST ' doubly-linked list of LONG values LOCAL node AS QUAD lst = lst.New lst.Add 20 ' [20] lst.Add 30 ' [20, 30] lst.AddHead 10 ' [10, 20, 30] PRINT "Head: "; lst.GetHead PRINT "Tail: "; lst.GetTail PRINT "Count: "; lst.Count ' walk the list with node cursors node = lst.First DO WHILE node <> 0 PRINT lst.Value(node); node = lst.Next(node) LOOP PRINT PRINT "Removed head: "; lst.RemoveHead PRINT "New head: "; lst.GetHead lst.Final FUNCTION = 0 END FUNCTION

LNLST API: .Add, .AddHead, .GetHead, .GetTail, .RemoveHead, .RemoveTail, .First, .Next, .Prev, .Value, .InsAfter, .InsBefore, .Remove, .Count, .Clear. Walk the list with .First, .Next and .Value.

Deque - Double-Ended Queue

Efficient double-ended queue with O(1) operations at both ends.

Deque - Fast at both ends
#COMPILE EXE #DIM ALL FUNCTION PBMAIN() AS LONG LOCAL d AS LNDEQUE ' double-ended queue of LONG values d = d.New d.PushFront 20 d.PushBack 30 d.PushFront 10 PRINT "Front: "; d.PeekFront ' 10 PRINT "Back: "; d.PeekBack ' 30 PRINT "Count: "; d.Count ' 3 PRINT "PopFront: "; d.PopFront ' 10 PRINT "PopBack: "; d.PopBack ' 30 PRINT "Left: "; d.Count ' 1 d.Final FUNCTION = 0 END FUNCTION

LNDEQUE API: .PushFront, .PushBack, .PopFront, .PopBack, .PeekFront, .PeekBack, .Count, .Empty, .Clear.

Set & Hash Table

Sorted set of unique 32-bit keys (LNSET) and hash table (LNLNHSH, O(1) average).

Set & Hash Table
#COMPILE EXE #DIM ALL FUNCTION PBMAIN() AS LONG LOCAL s AS LNSET ' sorted set of unique LONG values LOCAL h AS LNLNHSH ' hash table: LONG key -> LONG value s = s.New s.Add 3 s.Add 1 s.Add 2 s.Add 3 ' ignored - duplicate PRINT "Set count: "; s.Count ' 3 PRINT "Smallest: "; s.First ' 1 PRINT "After 1: "; s.Next(1) ' 2 PRINT "Has 2: "; s.Contains(2) ' non-zero h = h.New h.Put 1, 100 h.Put 2, 200 PRINT "Hash 2 -> "; h.Get(2) ' 200 PRINT "Hash 9 -> "; h.TryGet(9, 0) ' 0 (default) s.Final : h.Final FUNCTION = 0 END FUNCTION

LNSET API: .Add, .Remove, .Contains, .Count, .First, .Next, .ToArray, .Clear.
LNLNHSH API: .Put, .Get, .TryGet, .Remove, .Contains, .Keys, .Count, .Clear.

Try it yourself

CLI - compile and run
REM Map example PBXB64 test_map.pb -o test_map.exe test_map.exe REM Vector example PBXB64 test_vector.pb -o test_vector.exe test_vector.exe REM All containers PBXB64 test_containers.pb -o test_containers.exe test_containers.exe

All test files are in examples/basic/ - compile and run to verify.

Back to feature list