I have the following loop (where: Array<T> elements;
):
while (lengths[tempElement] == START) {
T next = elements[tempElement];
elements[tempElement] = elementToFind;
tempElement = next;
}
I would like to use the following swap
function:
void swap(T& firstElement, T& secondElement) {
T temp = firstElement;
firstElement = secondElement;
secondElement = temp;
}
In order to shorten the code. So I used:
swap(elements[tempElement],elementToFind);
But I think it does not do what I expect. How can I use that swap function?