Array Algorithms

The Array Algorithms component contains parallel versions of many common algorithms that operate on ranges of arrays. It contains the same methods as the Iterator Algorithms component, but the methods operate on generic array ranges T[ ] in order to take advantage of built-in array speed.

Algorithms are grouped into the following static classes based on their actions on arrays. Therefore, it is easy to use and memorize them.

Class Algorithms Example Methods
Algobase Basic algorithms that operate on ranges of arrays. Compare, Copy, Count, Equal, ForEach, LexicographicalCompare, Max, Min, Mismatch, Swap, Transform
AlterOper Algorithms that modify array elements. Fill, Remove, Replace
HeapOper Basic operations of a heap data structure. IsHeap, MakeHeap, PopHeap, PushHeap, SortHeap
NumericOper Algorithms that are generalizations of basic numeric operations. Accumulate, AdjacentDifference, InnerProduct, PartialSum
ReorderOper Algorithms that put the elements of the input range into a different order without changing, eliminating or introducing elements. Arrangements, Combinations, Factorial, NextPermutation, Partition, PrevPermutation, RandomSample, RandomShuffle, Reverse, Rotate, StablePartition
SearchOper Algorithms that return information about the elements in the range without changing the elements. AdjacentFind, BinarySearch, EqualRange, Find, LowerBound, Search, UpperBound
SetOper Basic operations of set theory. Except, Includes, Intersect, SymmetricExcept, Union
SortOper Algorithms that sort ranges or operate on sorted ranges of arrays. InplaceMerge, IsSorted, Merge, PartialSort, Sort, StableSort
TestOper Algorithms that test ranges of arrays. Any, Equal, None

Algorithms operate on a linear range of elements [first, last). This notation comes from mathematics. It is written in this asymmetric form to emphasize that [first, last) is a half-open interval that includes first but not last.

Better by Design:

  • All algorithms are very efficient and can compete with the performance of their non-generic counterparts. We do not abstract an algorithm in such a way that it becomes inefficient when you instantiate it back.
  • The majority of algorithms have a parallel version that scales linearly with the number of cores, particularly for ranges with a large number of elements. The only difference between the sequential and parallel version is in the name; the parallel version is prefixed with "P" (e.g. Sort vs. PSort, Copy vs. PCopy).
  • The user is completely isolated from parallel programming pitfalls: threads, locks, race conditions, cache coherency, etc.