---
title: "swapElements(_:_:)"
framework: accelerate
role: symbol
role_heading: Type Method
path: "accelerate/vdsp/swapelements(_:_:)-96xn7"
---

# swapElements(_:_:)

Swaps the elements of two single-precision vectors.

## Declaration

```swift
static func swapElements<T, U>(_ vectorA: inout T, _ vectorB: inout U) where T : AccelerateMutableBuffer, U : AccelerateMutableBuffer, T.Element == Float, U.Element == Float
```

## Parameters

- `vectorA`: The first vector.
- `vectorB`: The second vector.

## Discussion

Discussion The following code swaps the elements in vectorA with those in vectorB: var vectorA: [Float] = [1, 3, 5, 7] var vectorB: [Float] = [2, 4, 6, 8]

vDSP.swapElements(&vectorA,                   &vectorB)

// Prints "[2.0, 4.0, 6.0, 8.0]". print(vectorA)

// Prints "[1.0, 3.0, 5.0, 7.0]". print(vectorB)

## See Also

### Vector-to-vector element swapping functions

- [swapElements(_:_:)](accelerate/vdsp/swapelements(_:_:)-62wvt.md)
