started tile serializing

This commit is contained in:
2019-11-10 04:29:59 +03:00
parent f442dc6921
commit 3251d00dac
8 changed files with 155 additions and 51 deletions

View File

@ -1,9 +1,5 @@
package util
import (
"reflect"
)
func IntInSlice(needle int, haystack[]int) (exists bool, index int) {
exists = false
index = -1
@ -16,21 +12,21 @@ func IntInSlice(needle int, haystack[]int) (exists bool, index int) {
}
//left here for historical reasons
func InArray(val interface{}, array interface{}) (exists bool, index int) {
exists = false
index = -1
switch reflect.TypeOf(array).Kind() {
case reflect.Slice:
s := reflect.ValueOf(array)
for i := 0; i < s.Len(); i++ {
if reflect.DeepEqual(val, s.Index(i).Interface()) == true {
index = i
exists = true
return
}
}
}
return
}
//func InArray(val interface{}, array interface{}) (exists bool, index int) {
// exists = false
// index = -1
//
// switch reflect.TypeOf(array).Kind() {
// case reflect.Slice:
// s := reflect.ValueOf(array)
//
// for i := 0; i < s.Len(); i++ {
// if reflect.DeepEqual(val, s.Index(i).Interface()) == true {
// index = i
// exists = true
// return
// }
// }
// }
// return
//}