Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
array_utils.H File Reference

Utility functions for array manipulation. More...

#include <cstdlib>
#include <cassert>
#include <stdexcept>
#include <ah-errors.H>
#include <iostream>
#include <utility>
Include dependency graph for array_utils.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Functions

template<class Tarray >
void Aleph::open_gap (Tarray &ptr, size_t n, size_t pos=0, size_t num_entries=1)
 Open a gap in an array by shifting elements right.
 
template<typename T >
void Aleph::close_gap (T *ptr, size_t n, size_t pos, size_t num_entries=1)
 Close a gap in an array by shifting elements left.
 
template<typename T >
void Aleph::reverse (T *ptr, const size_t n) noexcept
 Reverse an array in-place.
 
template<typename T >
void Aleph::rotate_left (T *ptr, const size_t n, size_t m) noexcept
 Rotate array elements left by m positions.
 
template<typename T >
void Aleph::rotate_right (T *ptr, const size_t n, size_t m) noexcept
 Rotate array elements right by m positions.
 

Detailed Description

Utility functions for array manipulation.

This file provides efficient algorithms for manipulating contiguous arrays including gap operations and rotations.

Functions

Function Description Complexity
open_gap Insert space at position O(n)
close_gap Remove elements at position O(n)
reverse Reverse array in-place O(n)
rotate_left Rotate elements left O(n)
rotate_right Rotate elements right O(n)

Usage Example

int arr[] = {1, 2, 3, 4, 5};
// Rotate left by 2: {3, 4, 5, 1, 2}
Aleph::rotate_left(arr, 5, 2);
// Reverse: {2, 1, 5, 4, 3}
void reverse(Itor beg, Itor end)
Reverse elements in a range.
Definition ahAlgo.H:1094
void rotate_left(T *ptr, const size_t n, size_t m) noexcept
Rotate array elements left by m positions.
Author
Leandro Rabindranath León

Definition in file array_utils.H.