add swap method on all lists

This commit is contained in:
Emir Pasic
2015-03-14 00:36:10 +01:00
parent c50f07c2ac
commit 9f6dbf940a
6 changed files with 64 additions and 33 deletions
+1 -1
View File
@@ -142,7 +142,7 @@ func (list *List) Sort(comparator utils.Comparator) {
utils.Sort(list.elements[:list.size], comparator)
}
// Swaps two elements with the given indices.
// Swaps values of two elements at the given indices.
func (list *List) Swap(i, j int) {
if list.withinRange(i) && list.withinRange(j) {
list.elements[i], list.elements[j] = list.elements[j], list.elements[i]