Class ShellPointerArray

Class Documentation

class ShellPointerArray
[source]

Flat array of Shell pointers that supports in-place shuffle/reverse.

Built from the linked list of tests held by Registry so that O(n) random access is available for shuffling. Call relink_tests_in_order() after sorting to restore the linked-list structure. Used by Registry::shuffle_tests() and Registry::reverse_tests().

Public Functions

ShellPointerArray(Shell *first_test)

Build the array by walking the linked list starting at first_test.

Parameters:

first_test – Head of the Shell linked list.

~ShellPointerArray()
[source]
void shuffle(size_t seed)

Shuffle the array using a seeded Fisher-Yates algorithm.

Parameters:

seed – Seed for the rand() function pointer.

void reverse()
[source]

Reverse the order of the array.

Rewrite the Shell next-pointers to match the current array order.

Shell *get_first_test() const
Returns:

The first Shell in the (possibly reordered) array.

Shell *get(size_t index) const

Random-access into the array.

Parameters:

index – Zero-based index.

Returns:

The Shell at index, or nullptr if out of range.