Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
Loading...
Searching...
No Matches
array_left_rotation.cpp File Reference

Implementation for the Array Left Rotation algorithm. More...

#include <cassert>
#include <iostream>
#include <vector>
Include dependency graph for array_left_rotation.cpp:

Namespaces

namespace  operations_on_datastructures
 for std::vector
 
namespace  tests
 Testcases to check Union of Two Arrays.
 

Functions

void operations_on_datastructures::print (const std::vector< int32_t > &array)
 Prints the values of a vector sequentially, ending with a newline character.
 
std::vector< int32_t > operations_on_datastructures::shift_left (const std::vector< int32_t > &array, size_t shift)
 Shifts the given vector to the left by the shift amount and returns a new vector with the result. The original vector is not mutated.
 
void tests::test1 ()
 A Test to check an simple case.
 
void tests::test2 ()
 A Test to check an empty vector.
 
void tests::test3 ()
 A Test to check an invalid shift value.
 
void tests::test4 ()
 A Test to check a very large input.
 
void tests::test5 ()
 A Test to check a shift of zero.
 
static void test ()
 Function to test the correctness of shift_left() function.
 
int main ()
 main function
 

Detailed Description

Implementation for the Array Left Rotation algorithm.

Shifting an array to the left involves moving each element of the array so that it occupies a position of a certain shift value before its current one. This implementation uses a result vector and does not mutate the input.

Author
Alvin

Function Documentation

◆ main()

int main ( void )

main function

Returns
0 on exit
171 {
172 test(); // run self-test implementations
173 return 0;
174}
static void test()
Function to test the correctness of shift_left() function.
Definition array_left_rotation.cpp:159
Here is the call graph for this function:

◆ test()

static void test ( )
static

Function to test the correctness of shift_left() function.

Returns
void
159 {
160 tests::test1();
161 tests::test2();
162 tests::test3();
163 tests::test4();
164 tests::test5();
165}
void test1()
A Test to check an simple case.
Definition array_left_rotation.cpp:75
void test4()
A Test to check a very large input.
Definition array_left_rotation.cpp:120
void test3()
A Test to check an invalid shift value.
Definition array_left_rotation.cpp:105
void test2()
A Test to check an empty vector.
Definition array_left_rotation.cpp:90
void test5()
A Test to check a shift of zero.
Definition array_left_rotation.cpp:143
Here is the call graph for this function: