Move first/last unique elements utility functions to android package

Move firstUniqueElements to android.FirstUniqueStrings,
lastUniqueElements to android.LastUniqueStrings, and lastUniquePaths
to android.LastUniquePaths.

Test: m checkbuild
Change-Id: Ieac840405126c7f8f98afb4a4ef35c01a18fe7fb
diff --git a/android/paths.go b/android/paths.go
index 7443547..d6a1c66 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -286,8 +286,8 @@
 	return ret
 }
 
-// FirstUniqueElements returns all unique elements of a slice, keeping the first copy of each
-// modifies the slice contents in place, and returns a subslice of the original slice
+// FirstUniquePaths returns all unique elements of a Paths, keeping the first copy of each.  It
+// modifies the Paths slice contents in place, and returns a subslice of the original slice.
 func FirstUniquePaths(list Paths) Paths {
 	k := 0
 outer:
@@ -303,6 +303,24 @@
 	return list[:k]
 }
 
+// LastUniquePaths returns all unique elements of a Paths, keeping the last copy of each.  It
+// modifies the Paths slice contents in place, and returns a subslice of the original slice.
+func LastUniquePaths(list Paths) Paths {
+	totalSkip := 0
+	for i := len(list) - 1; i >= totalSkip; i-- {
+		skip := 0
+		for j := i - 1; j >= totalSkip; j-- {
+			if list[i] == list[j] {
+				skip++
+			} else {
+				list[j+skip] = list[j]
+			}
+		}
+		totalSkip += skip
+	}
+	return list[totalSkip:]
+}
+
 func indexPathList(s Path, list []Path) int {
 	for i, l := range list {
 		if l == s {