Example #1
0
// For a slice, a negative pos k means append at end
func (a *ArrayList) Add_L(k K, v V) {
	i := k.(int)
	if i >= 0 && i <= len(a.Data)-1 {
		tmp := make([]string, 0)
		tmp = generic.Append(tmp, v).Interface().([]string)
		tmp = append(tmp, a.Data[i:]...)
		a.Data = append(a.Data[0:i], tmp...)
	} else {
		a.Data = generic.Append(a.Data, v).Interface().([]string)
	}
}
Example #2
0
// For a slice, a negative pos k means append at end
func (s *Set) Add_L(k K, v V) {
	i := k.(int)
	if i >= 0 && i <= len(s.Data)-1 {
		tmp := make([]string, 0)
		tmp = generic.Append(tmp, v).Interface().([]string)
		tmp = append(tmp, s.Data[i:]...)
		s.Data = append(s.Data[0:i], tmp...)
	} else {
		s.Data = generic.Append(s.Data, v).Interface().([]string)
	}
}
Example #3
0
func RemoveByV_L(list L, v V) {
	keys := generic.MakeSlice(list.TypeK_L()).Interface()
	vs := generic.ValueOf(v)
	for i := 0; i < vs.Len(); i++ {
		val := vs.Index(i).Interface()
		key := KeyOf_L(list, val)
		if key != nil {
			keys = generic.Append(keys, key).Interface()
		}
	}
	list.Remove_L(keys)
}
Example #4
0
func Iterator_L(list L) V {
	v := generic.MakeSlice(list.Values_L()).Interface()
	return generic.Append(v, list.Values_L()).Interface()
}
Example #5
0
func KeySet_L(list L) K {
	k := generic.MakeSlice(list.Keys_L()).Interface()
	return generic.Append(k, list.Keys_L()).Interface()
}