-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraySorter.h
More file actions
38 lines (26 loc) · 1.04 KB
/
ArraySorter.h
File metadata and controls
38 lines (26 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <ostream>
class ArraySorter
{
private:
int* fArrayOfNumbers;
unsigned int fArraySize;
protected:
// service member function to be called once a sorting step has been finished
void stepCompleted( std::ostream& aOStream );
// swap elements in the underlying array
void swapElements( unsigned int aSourcIndex, unsigned int aTargetIndex );
public:
// array sorter constructor
ArraySorter( const int aArrayOfNumbers[], unsigned int aArraySize );
// array sorter destructor
virtual ~ArraySorter();
// return array element at index
const unsigned int at( unsigned int aIndex ) const;
// return size of underlying array
const unsigned int getRange() const;
// polymorphic sort function (takes an output stream to call stepCompleted)
virtual void sort( std::ostream& aOStream );
// output operator for array sorters
friend std::ostream& operator<<( std::ostream& aOStream, const ArraySorter& aObject );
};