Megosztás a következőn keresztül:


slice Class

A utility class to valarray that is used to define one-dimensional subsets of a parent valarray. If a valarray is regarded as a two-dimensional matrix with all elements in an array, then the slice extracts a vector in one dimension out of the two-dimensional array.

Remarks

The class stores the parameters that characterize an object of type slice_array The subset of a valarray is indirectly constructed when an object of class slice appears as an argument for an object of class valarray<Type>. The stored values that specify the subset selected from the parent valarray include:

  • A starting index in the valarray.

  • A total length, or number of elements in the slice.

  • A stride, or distance between subsequent indices of elements in the valarray.

If the set defined by a slice is the subset of a constant valarray, then the slice is a new valarray. If the set defined by a slice is the subset of a nonconstant valarray, then the slice has reference semantics to the original valarray. The evaluation mechanism for nonconstant valarrays saves time and memory.

Operations on valarrays are guaranteed only if the source and destination subsets defined by the slices are distinct and all indices are valid.

Constructors

slice

Defines a subset of a valarray that consists of a number of elements that are an equal distance apart and that start at a specified element.

Member Functions

size

Finds the number of elements in a slice of a valarray.

start

Finds the starting index of a slice of a valarray.

stride

Finds the distance between elements in a slice of a valarray.

Requirements

Header: <valarray>

Namespace: std

See Also

Reference

Thread Safety in the C++ Standard Library