Code Monkey home page Code Monkey logo

isemenkov / libpasc-algorithms Goto Github PK

View Code? Open in Web Editor NEW
26.0 2.0 10.0 442 KB

libPasC-Algorithms is delphi and object pascal library of common data structures and algorithms. The library is a set of containers adapted for the Pascal language and the template system available on it.

License: MIT License

Pascal 99.82% Shell 0.18%
fpc freepascal pascal algorithms data-structures delphi delphi10 delphi-library pascal-library libpasc-algorithms

libpasc-algorithms's Introduction

libPasC-Algorithms

libPasC-Algorithms is delphi and object pascal library of common data structures and algorithms. The library is based on the c-algorithms repository and it is a set of containers adapted for the Pascal language and the template system available on it.

Table of contents

Requirements

Library is tested for

  • Embarcadero (R) Delphi 10.3 on Windows 7 Service Pack 1 (Version 6.1, Build 7601, 64-bit Edition)
  • Embarcadero (R) Delphi 11.0 Version 28.0.42600.6491 on Windows 10 (Version 10.0, Build 19042, 64-bit Edition)
  • FreePascal Compiler (3.2.0) and Lazarus IDE (2.0.12) on Ubuntu Linux 5.8.0-33-generic x86_64

Installation

Get the sources and add the source directory to the project search path. For FPC add the source directory to the fpc.cfg file.

Usage

Clone the repository git clone https://github.com/isemenkov/libpasc-algorithms.

Add the unit you want to use to the uses clause.

Testing

A testing framework consists of the following ingredients:

  1. Test runner project located in unit-tests directory.
  2. Test cases (DUnit for Delphi and FPCUnit for FPC based) for all containers classes.

Containers

TArrayList

TArrayList are generic arrays of T which automatically increase in size.

uses
  container.arraylist, utils.functor;
  
type
  generic TArrayList<T, BinaryCompareFunctor> = class

BinaryCompareFunctor is based on utils.functor.TBinaryFunctor interface and used to compare two array items. Needed for sort and search functions.

More details read on wiki page.

TMultiArray

TMultiArray is a generic array of array of T which automatically increase in size.

uses
  container.multiarray, utils.functor;
  
type
  generic TMultiArray<T, BinaryCompareFunctor> = class

BinaryCompareFunctor is based on utils.functor.TBinaryFunctor interface and used to compare two array items. Needed for sort and search functions.

More details read on wiki page.

TSortedArray

The TSortedArray is an automatically resizing array which stores its elements in sorted order. User defined functor determine the sorting order. All operations on a TSortedArray maintain the sorted property. Most operations are done in O(n) time, but searching can be done in O(log n) worst case.

uses
  container.sortedarray, utils.functor;
  
type
  generic TSortedArray<T, BinaryCompareFunctor> = class

BinaryCompareFunctor is based on utils.functor.TBinaryFunctor interface and used to compare two array items. Needed for search function.

More details read on wiki page.

TList

A doubly-linked list stores a collection of values. Each entry in the list contains a link to the next entry and the previous entry. It is therefore possible to iterate over entries in the list in either direction.

uses
  container.list, utils.functor;

type
  generic TList<T, BinaryCompareFunctor> = class

BinaryCompareFunctor is based on utils.functor.TBinaryFunctor interface and used to compare two list items. Needed for sort and search functions.

More details read on wiki page.

TAvlTree

The AVL tree structure is a balanced binary tree which stores a collection of nodes. Each node has a key and a value associated with it. The nodes are sorted within the tree based on the order of their keys. Modifications to the tree are constructed such that the tree remains balanced at all times (there are always roughly equal numbers of nodes on either side of the tree).

Balanced binary trees have several uses. They can be used as a mapping (searching for a value based on its key), or as a set of keys which is always ordered.

uses
  container.avltree;
 
type
  generic TAvlTree<K, V, KeyBinaryCompareFunctor> = class

KeyBinaryCompareFunctor is based on utils.functor.TBinaryFunctor interface and used to compare two keys.

More details read on wiki page.

THashTable

A hash table stores a set of values which can be addressed by a key. Given the key, the corresponding value can be looked up quickly.

uses
  container.hashtable, utils.functor;
 
type
  generic THashTable<K, V, KeyBinaryCompareFunctor> = class

KeyBinaryCompareFunctor is based on utils.functor.TBinaryFunctor interface and used to compare two keys.

More details read on wiki page.

TMultiHash

A multi hash table stores a set of values which can be addressed by a key. Given the key, the corresponding value can be looked up quickly.

uses
  container.hashtable, container.multihash, utils.functor;
 
type
  generic TMultiHash<K, V, KeyBinaryCompareFunctor, ValueBinaryCompareFunctor> = class

KeyBinaryCompareFunctor and ValueBinaryCompareFunctor is based on utils.functor.TBinaryFunctor interface and used to compare two keys.

More details read on wiki page.

TOrderedSet

A set stores a collection of values. Each value can only exist once in the set.

uses
  container.orderedset, utils.functor;

type
  generic TOrderedSet<V, BinaryCompareFunctor> = class

BinaryCompareFunctor is based on utils.functor.TBinaryFunctor interface and used to compare two items.

More details read on wiki page.

TMinBinaryHeap

Heap type. The values with the lowest priority are stored at the top of the heap and will be the first returned.

uses
  container.binaryheap, utils.functor;

type
  generic TMinBinaryHeap<V, BinaryCompareFunctor> = class

BinaryCompareFunctor is based on utils.functor.TBinaryFunctor interface and used to compare two items.

More details read on wiki page.

TMaxBinaryHeap

Heap type. The values with the greatest priority are stored at the top of the heap and will be the first returned.

uses
  container.binaryheap, utils.functor;

type
  generic TMaxBinaryHeap<V, BinaryCompareFunctor> = class

BinaryCompareFunctor is based on utils.functor.TBinaryFunctor interface and used to compare two items.

More details read on wiki page.

TTrie

A trie is a data structure which provides fast mappings from strings to values.

uses
  container.trie;

type
  generic TTrie<V> = class

More details read on wiki page.

TQueue

A double ended queue stores a list of values in order. New values can be added and removed from either end of the queue.

uses
  container.queue;

type
  generic TQueue<T> = class

More details read on wiki page.

TMemoryBuffer

TMemoryBuffer is a useful data structure for storing arbitrary sized blocks of memory. It is guarantees deletion of the memory block when the object is destroyed. This class based on wxWidgets wxMemoryBuffer api interface https://docs.wxwidgets.org/trunk/classwx_memory_buffer.html.

uses
  container.memorybuffer;

type
  TMemoryBuffer = class

More details read on wiki page.

libpasc-algorithms's People

Contributors

isemenkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.