GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
octave_sort< T > Class Template Reference

#include "oct-sort.h"

Collaboration diagram for octave_sort< T >:

Classes

struct  MergeState
 
struct  s_slice
 

Public Types

typedef bool(* compare_fcn_type) (typename ref_param< T >::type, typename ref_param< T >::type)
 

Public Member Functions

 octave_sort (compare_fcn_type)
 
 octave_sort (const octave_sort &)=delete
 
 octave_sort (void)
 
 ~octave_sort (void)
 
bool is_sorted_rows (const T *data, octave_idx_type rows, octave_idx_type cols)
 
bool issorted (const T *data, octave_idx_type nel)
 
octave_idx_type lookup (const T *data, octave_idx_type nel, const T &value)
 
void lookup (const T *data, octave_idx_type nel, const T *values, octave_idx_type nvalues, octave_idx_type *idx)
 
void lookup_sorted (const T *data, octave_idx_type nel, const T *values, octave_idx_type nvalues, octave_idx_type *idx, bool rev=false)
 
void nth_element (T *data, octave_idx_type nel, octave_idx_type lo, octave_idx_type up=-1)
 
octave_sortoperator= (const octave_sort &)=delete
 
void set_compare (compare_fcn_type comp)
 
void set_compare (sortmode mode)
 
void sort (bool *data, octave_idx_type *idx, octave_idx_type nel, std::greater< bool >)
 
void sort (bool *data, octave_idx_type *idx, octave_idx_type nel, std::less< bool >)
 
void sort (bool *data, octave_idx_type nel, std::greater< bool >)
 
void sort (bool *data, octave_idx_type nel, std::less< bool >)
 
void sort (T *data, octave_idx_type *idx, octave_idx_type nel)
 
void sort (T *data, octave_idx_type nel)
 
void sort_rows (const T *data, octave_idx_type *idx, octave_idx_type rows, octave_idx_type cols)
 

Static Public Member Functions

static bool ascending_compare (typename ref_param< T >::type, typename ref_param< T >::type)
 
static bool descending_compare (typename ref_param< T >::type, typename ref_param< T >::type)
 

Private Member Functions

template<typename Comp >
void binarysort (T *data, octave_idx_type *idx, octave_idx_type nel, octave_idx_type start, Comp comp)
 
template<typename Comp >
void binarysort (T *data, octave_idx_type nel, octave_idx_type start, Comp comp)
 
template<typename Comp >
octave_idx_type count_run (T *lo, octave_idx_type n, bool &descending, Comp comp)
 
template<typename Comp >
octave_idx_type gallop_left (T key, T *a, octave_idx_type n, octave_idx_type hint, Comp comp)
 
template<typename Comp >
octave_idx_type gallop_right (T key, T *a, octave_idx_type n, octave_idx_type hint, Comp comp)
 
template<typename Comp >
bool is_sorted_rows (const T *data, octave_idx_type rows, octave_idx_type cols, Comp comp)
 
template<typename Comp >
bool issorted (const T *data, octave_idx_type nel, Comp comp)
 
template<typename Comp >
octave_idx_type lookup (const T *data, octave_idx_type nel, const T &value, Comp comp)
 
template<typename Comp >
void lookup (const T *data, octave_idx_type nel, const T *values, octave_idx_type nvalues, octave_idx_type *idx, Comp comp)
 
template<typename Comp >
void lookup_sorted (const T *data, octave_idx_type nel, const T *values, octave_idx_type nvalues, octave_idx_type *idx, bool rev, Comp comp)
 
template<typename Comp >
int merge_at (octave_idx_type i, T *data, Comp comp)
 
template<typename Comp >
int merge_at (octave_idx_type i, T *data, octave_idx_type *idx, Comp comp)
 
template<typename Comp >
int merge_collapse (T *data, Comp comp)
 
template<typename Comp >
int merge_collapse (T *data, octave_idx_type *idx, Comp comp)
 
octave_idx_type merge_compute_minrun (octave_idx_type n)
 
template<typename Comp >
int merge_force_collapse (T *data, Comp comp)
 
template<typename Comp >
int merge_force_collapse (T *data, octave_idx_type *idx, Comp comp)
 
template<typename Comp >
int merge_hi (T *pa, octave_idx_type *ipa, octave_idx_type na, T *pb, octave_idx_type *ipb, octave_idx_type nb, Comp comp)
 
template<typename Comp >
int merge_hi (T *pa, octave_idx_type na, T *pb, octave_idx_type nb, Comp comp)
 
template<typename Comp >
int merge_lo (T *pa, octave_idx_type *ipa, octave_idx_type na, T *pb, octave_idx_type *ipb, octave_idx_type nb, Comp comp)
 
template<typename Comp >
int merge_lo (T *pa, octave_idx_type na, T *pb, octave_idx_type nb, Comp comp)
 
template<typename Comp >
void nth_element (T *data, octave_idx_type nel, octave_idx_type lo, octave_idx_type up, Comp comp)
 
template<typename Comp >
void sort (T *data, octave_idx_type *idx, octave_idx_type nel, Comp comp)
 
template<typename Comp >
void sort (T *data, octave_idx_type nel, Comp comp)
 
template<typename Comp >
void sort_rows (const T *data, octave_idx_type *idx, octave_idx_type rows, octave_idx_type cols, Comp comp)
 

Private Attributes

compare_fcn_type m_compare
 
MergeStatem_ms
 

Static Private Attributes

static const int MAX_MERGE_PENDING = 85
 
static const int MERGESTATE_TEMP_SIZE = 1024
 
static const int MIN_GALLOP = 7
 

Detailed Description

template<typename T>
class octave_sort< T >

Definition at line 98 of file oct-sort.h.

Member Typedef Documentation

◆ compare_fcn_type

template<typename T >
typedef bool(* octave_sort< T >::compare_fcn_type) (typename ref_param< T >::type, typename ref_param< T >::type)

Definition at line 103 of file oct-sort.h.

Constructor & Destructor Documentation

◆ octave_sort() [1/3]

template<typename T >
octave_sort< T >::octave_sort ( void  )

Definition at line 123 of file oct-sort.cc.

◆ octave_sort() [2/3]

template<typename T >
octave_sort< T >::octave_sort ( compare_fcn_type  comp)

Definition at line 128 of file oct-sort.cc.

◆ octave_sort() [3/3]

template<typename T >
octave_sort< T >::octave_sort ( const octave_sort< T > &  )
delete

◆ ~octave_sort()

template<typename T >
octave_sort< T >::~octave_sort ( void  )

Definition at line 133 of file oct-sort.cc.

Member Function Documentation

◆ ascending_compare()

template<typename T >
bool octave_sort< T >::ascending_compare ( typename ref_param< T >::type  x,
typename ref_param< T >::type  y 
)
static

◆ binarysort() [1/2]

template<typename T >
template<typename Comp >
void octave_sort< T >::binarysort ( T *  data,
octave_idx_type idx,
octave_idx_type  nel,
octave_idx_type  start,
Comp  comp 
)
private

Definition at line 198 of file oct-sort.cc.

References r.

◆ binarysort() [2/2]

template<typename T >
template<typename Comp >
void octave_sort< T >::binarysort ( T *  data,
octave_idx_type  nel,
octave_idx_type  start,
Comp  comp 
)
private

Definition at line 153 of file oct-sort.cc.

References r.

Referenced by octave_sort< T >::sort().

◆ count_run()

template<typename T >
template<typename Comp >
octave_idx_type octave_sort< T >::count_run ( T *  lo,
octave_idx_type  n,
bool &  descending,
Comp  comp 
)
private

Definition at line 265 of file oct-sort.cc.

References n.

Referenced by octave_sort< T >::sort().

◆ descending_compare()

template<typename T >
bool octave_sort< T >::descending_compare ( typename ref_param< T >::type  x,
typename ref_param< T >::type  y 
)
static

◆ gallop_left()

template<typename T >
template<typename Comp >
octave_idx_type octave_sort< T >::gallop_left ( key,
T *  a,
octave_idx_type  n,
octave_idx_type  hint,
Comp  comp 
)
private

Definition at line 325 of file oct-sort.cc.

References m, and n.

Referenced by octave_sort< T >::merge_at(), octave_sort< T >::merge_hi(), and octave_sort< T >::merge_lo().

◆ gallop_right()

template<typename T >
template<typename Comp >
octave_idx_type octave_sort< T >::gallop_right ( key,
T *  a,
octave_idx_type  n,
octave_idx_type  hint,
Comp  comp 
)
private

Definition at line 420 of file oct-sort.cc.

References m, and n.

Referenced by octave_sort< T >::merge_at(), octave_sort< T >::merge_hi(), and octave_sort< T >::merge_lo().

◆ is_sorted_rows() [1/2]

template<typename T >
bool octave_sort< T >::is_sorted_rows ( const T *  data,
octave_idx_type  rows,
octave_idx_type  cols 
)

◆ is_sorted_rows() [2/2]

template<typename T >
template<typename Comp >
bool octave_sort< T >::is_sorted_rows ( const T *  data,
octave_idx_type  rows,
octave_idx_type  cols,
Comp  comp 
)
private

Definition at line 1681 of file oct-sort.cc.

References octave_sort< T >::issorted(), and n.

◆ issorted() [1/2]

template<typename T >
bool octave_sort< T >::issorted ( const T *  data,
octave_idx_type  nel 
)

◆ issorted() [2/2]

template<typename T >
template<typename Comp >
bool octave_sort< T >::issorted ( const T *  data,
octave_idx_type  nel,
Comp  comp 
)
private

Definition at line 1554 of file oct-sort.cc.

References octave::next.

◆ lookup() [1/4]

template<typename T >
octave_idx_type octave_sort< T >::lookup ( const T *  data,
octave_idx_type  nel,
const T &  value 
)

◆ lookup() [2/4]

template<typename T >
template<typename Comp >
octave_idx_type octave_sort< T >::lookup ( const T *  data,
octave_idx_type  nel,
const T &  value,
Comp  comp 
)
private

Definition at line 1764 of file oct-sort.cc.

◆ lookup() [3/4]

template<typename T >
void octave_sort< T >::lookup ( const T *  data,
octave_idx_type  nel,
const T *  values,
octave_idx_type  nvalues,
octave_idx_type idx 
)

◆ lookup() [4/4]

template<typename T >
template<typename Comp >
void octave_sort< T >::lookup ( const T *  data,
octave_idx_type  nel,
const T *  values,
octave_idx_type  nvalues,
octave_idx_type idx,
Comp  comp 
)
private

Definition at line 1808 of file oct-sort.cc.

References octave_sort< T >::lookup().

◆ lookup_sorted() [1/2]

template<typename T >
template<typename Comp >
void octave_sort< T >::lookup_sorted ( const T *  data,
octave_idx_type  nel,
const T *  values,
octave_idx_type  nvalues,
octave_idx_type idx,
bool  rev,
Comp  comp 
)
private

Definition at line 1842 of file oct-sort.cc.

◆ lookup_sorted() [2/2]

template<typename T >
void octave_sort< T >::lookup_sorted ( const T *  data,
octave_idx_type  nel,
const T *  values,
octave_idx_type  nvalues,
octave_idx_type idx,
bool  rev = false 
)

◆ merge_at() [1/2]

◆ merge_at() [2/2]

◆ merge_collapse() [1/2]

template<typename T >
template<typename Comp >
int octave_sort< T >::merge_collapse ( T *  data,
Comp  comp 
)
private

◆ merge_collapse() [2/2]

template<typename T >
template<typename Comp >
int octave_sort< T >::merge_collapse ( T *  data,
octave_idx_type idx,
Comp  comp 
)
private

◆ merge_compute_minrun()

template<typename T >
octave_idx_type octave_sort< T >::merge_compute_minrun ( octave_idx_type  n)
private

Definition at line 1386 of file oct-sort.cc.

References n, and r.

Referenced by octave_sort< T >::sort().

◆ merge_force_collapse() [1/2]

template<typename T >
template<typename Comp >
int octave_sort< T >::merge_force_collapse ( T *  data,
Comp  comp 
)
private

◆ merge_force_collapse() [2/2]

template<typename T >
template<typename Comp >
int octave_sort< T >::merge_force_collapse ( T *  data,
octave_idx_type idx,
Comp  comp 
)
private

◆ merge_hi() [1/2]

◆ merge_hi() [2/2]

◆ merge_lo() [1/2]

◆ merge_lo() [2/2]

◆ nth_element() [1/2]

template<typename T >
template<typename Comp >
void octave_sort< T >::nth_element ( T *  data,
octave_idx_type  nel,
octave_idx_type  lo,
octave_idx_type  up,
Comp  comp 
)
private

Definition at line 1918 of file oct-sort.cc.

◆ nth_element() [2/2]

template<typename T >
void octave_sort< T >::nth_element ( T *  data,
octave_idx_type  nel,
octave_idx_type  lo,
octave_idx_type  up = -1 
)

◆ operator=()

template<typename T >
octave_sort& octave_sort< T >::operator= ( const octave_sort< T > &  )
delete

◆ set_compare() [1/2]

◆ set_compare() [2/2]

template<typename T >
void octave_sort< T >::set_compare ( sortmode  mode)

Definition at line 140 of file oct-sort.cc.

References ASCENDING, and DESCENDING.

◆ sort() [1/8]

void octave_sort< bool >::sort ( bool *  data,
octave_idx_type idx,
octave_idx_type  nel,
std::greater< bool >   
)

Definition at line 115 of file Array-b.cc.

◆ sort() [2/8]

void octave_sort< bool >::sort ( bool *  data,
octave_idx_type idx,
octave_idx_type  nel,
std::less< bool >   
)

Definition at line 106 of file Array-b.cc.

◆ sort() [3/8]

void octave_sort< bool >::sort ( bool *  data,
octave_idx_type  nel,
std::greater< bool >   
)

Definition at line 97 of file Array-b.cc.

◆ sort() [4/8]

void octave_sort< bool >::sort ( bool *  data,
octave_idx_type  nel,
std::less< bool >   
)

Definition at line 88 of file Array-b.cc.

◆ sort() [5/8]

template<typename T >
void octave_sort< T >::sort ( T *  data,
octave_idx_type idx,
octave_idx_type  nel 
)

◆ sort() [6/8]

◆ sort() [7/8]

◆ sort() [8/8]

◆ sort_rows() [1/2]

template<typename T >
void octave_sort< T >::sort_rows ( const T *  data,
octave_idx_type idx,
octave_idx_type  rows,
octave_idx_type  cols 
)

◆ sort_rows() [2/2]

template<typename T >
template<typename Comp >
void octave_sort< T >::sort_rows ( const T *  data,
octave_idx_type idx,
octave_idx_type  rows,
octave_idx_type  cols,
Comp  comp 
)
private

Definition at line 1604 of file oct-sort.cc.

References OCTAVE_LOCAL_BUFFER, and octave_sort< T >::sort().

Member Data Documentation

◆ m_compare

◆ m_ms

◆ MAX_MERGE_PENDING

template<typename T >
const int octave_sort< T >::MAX_MERGE_PENDING = 85
staticprivate

Definition at line 173 of file oct-sort.h.

Referenced by octave_sort< T >::sort().

◆ MERGESTATE_TEMP_SIZE

template<typename T >
const int octave_sort< T >::MERGESTATE_TEMP_SIZE = 1024
staticprivate

Definition at line 180 of file oct-sort.h.

Referenced by octave_sort< T >::sort().

◆ MIN_GALLOP

template<typename T >
const int octave_sort< T >::MIN_GALLOP = 7
staticprivate

Definition at line 177 of file oct-sort.h.

Referenced by octave_sort< T >::merge_hi(), and octave_sort< T >::merge_lo().


The documentation for this class was generated from the following files: