Skip to content

About

A C++ class derived from std::vector that adds a method for rotating the contents of the vector 90º.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Rotatable Grid Vector Test

A class derived from std::vector<std::vector<T>> that provides a method to rotate the contents of the vector 90º in O(n) time.

Demo


A diagram explaining the algorithm to rotate the vector can be found below. In cases where total.rows > total.cols and total.cols > (total.rows+1)/2, a separate algorithm moves chunks of data around before the main rotation algorithm is used to avoid overwriting data in overlapping sections. The second diagram illustrates this process (dashed lines indicate empty cells). After the chunks are moved, the blue square is rotated.

Algorithm

Chunks

Diagrams created using diagrams.net

About

A C++ class derived from std::vector that adds a method for rotating the contents of the vector 90º.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages