Git Product home page Git Product logo

paspdqsort's Introduction

PasPDQSort

This is a direct translation of Orson Peters' PDQSort algorithm from C++ to Free Pascal, with one difference in that the internally-used-in-some-cases HeapSort algorithm is a translation of the one found in Stjepan Glavina's Rust implementation of PDQSort.

Basic usage (in the ObjFPC syntax mode) is as follows:

program Example;

{$mode ObjFPC}

uses Math, PasPDQSort;

var
  I: PtrInt;
  A: array of Int32;

begin
  // generate a random array for example purposes.
  Randomize();
  SetLength(A, 500);
  for I := 0 to 499 do
    A[I] := RandomRange(1, 1001);

  // sort it!
  specialize TPDQSorter<Int32>.Sort(A);

  // Note: This implementation of the algorithm requires that the type being sorted
  // (that is, the one `TPDQSorter` is specialized with) has an existing
  // implementation of the "less than" operator for it, and will fail to compile
  // if handed something for which that is not the case.

  // In the above example, "less than" happens to be built into the language for `Int32`,
  // but user-defined custom implementations of the operator for custom types will also work fine.
end.

Compatible with Free Pascal 3.1.1 and higher.

paspdqsort's People

Contributors

akira13641 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

atkins126 loop80

paspdqsort's Issues

Add inline?

Method Swap is called often. maybe mark it 'inline'?

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.