Skip to content

Commit

Permalink
added panic() conditions to enumerators
Browse files Browse the repository at this point in the history
  • Loading branch information
feyeleanor committed Feb 24, 2013
1 parent 220b24f commit df81e03
Show file tree
Hide file tree
Showing 25 changed files with 229 additions and 63 deletions.
13 changes: 11 additions & 2 deletions complex128.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (s *C128Slice) DeleteIf(f interface{}) {
}
}

default: p = len(a)
default: panic(f)
}
*s = a[:p]
}
Expand All @@ -152,6 +152,7 @@ func (s C128Slice) Each(f interface{}) {
case func(interface{}): for _, v := range s { f(v) }
case func(int, interface{}): for i, v := range s { f(i, v) }
case func(interface{}, interface{}): for i, v := range s { f(i, v) }
default: panic(f)
}
}

Expand Down Expand Up @@ -187,6 +188,7 @@ func (s C128Slice) While(f interface{}) int {
return i
}
}
default: panic(f)
}
return len(s)
}
Expand Down Expand Up @@ -223,6 +225,7 @@ func (s C128Slice) Until(f interface{}) int {
return i
}
}
default: panic(f)
}
return len(s)
}
Expand Down Expand Up @@ -255,6 +258,7 @@ func (s C128Slice) Overwrite(offset int, container interface{}) {
switch container := container.(type) {
case C128Slice: copy(s[offset:], container)
case []complex128: copy(s[offset:], container)
default: panic(container)
}
}

Expand Down Expand Up @@ -525,7 +529,7 @@ func (s *C128Slice) KeepIf(f interface{}) {
}
}

default: p = len(a)
default: panic(f)
}
*s = a[:p]
}
Expand All @@ -538,6 +542,7 @@ func (s C128Slice) ReverseEach(f interface{}) {
case func(interface{}): for i := len(s) - 1; i > -1; i-- { f(s[i]) }
case func(int, interface{}): for i := len(s) - 1; i > -1; i-- { f(i, s[i]) }
case func(interface{}, interface{}): for i := len(s) - 1; i > -1; i-- { f(i, s[i]) }
default: panic(f)
}
}

Expand All @@ -561,6 +566,8 @@ func (s C128Slice) ReplaceIf(f interface{}, r interface{}) {
s[i] = replacement
}
}

default: panic(f)
}
}

Expand Down Expand Up @@ -593,6 +600,8 @@ func (s C128Slice) Select(f interface{}) interface{} {
r = append(r, v)
}
}

default: panic(f)
}
return r
}
Expand Down
15 changes: 12 additions & 3 deletions complex64.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (s *C64Slice) DeleteIf(f interface{}) {
}
}

default: p = len(a)
default: panic(f)
}
*s = a[:p]
}
Expand All @@ -152,6 +152,7 @@ func (s C64Slice) Each(f interface{}) {
case func(interface{}): for _, v := range s { f(v) }
case func(int, interface{}): for i, v := range s { f(i, v) }
case func(interface{}, interface{}): for i, v := range s { f(i, v) }
default: panic(f)
}
}

Expand Down Expand Up @@ -187,6 +188,7 @@ func (s C64Slice) While(f interface{}) int {
return i
}
}
default: panic(f)
}
return len(s)
}
Expand Down Expand Up @@ -223,6 +225,7 @@ func (s C64Slice) Until(f interface{}) int {
return i
}
}
default: panic(f)
}
return len(s)
}
Expand Down Expand Up @@ -254,7 +257,8 @@ func (s C64Slice) BlockClear(start, count int) {
func (s C64Slice) Overwrite(offset int, container interface{}) {
switch container := container.(type) {
case C64Slice: copy(s[offset:], container)
case []complex64: copy(s[offset:], container)
case []complex64: copy(s[offset:], container)
default: panic(container)
}
}

Expand Down Expand Up @@ -553,7 +557,7 @@ func (s *C64Slice) KeepIf(f interface{}) {
}
}

default: p = len(a)
default: panic(f)
}
*s = a[:p]
}
Expand All @@ -566,6 +570,7 @@ func (s C64Slice) ReverseEach(f interface{}) {
case func(interface{}): for i := len(s) - 1; i > -1; i-- { f(s[i]) }
case func(int, interface{}): for i := len(s) - 1; i > -1; i-- { f(i, s[i]) }
case func(interface{}, interface{}): for i := len(s) - 1; i > -1; i-- { f(i, s[i]) }
default: panic(f)
}
}

Expand All @@ -589,6 +594,8 @@ func (s C64Slice) ReplaceIf(f interface{}, r interface{}) {
s[i] = replacement
}
}

default: panic(f)
}
}

Expand Down Expand Up @@ -621,6 +628,8 @@ func (s C64Slice) Select(f interface{}) interface{} {
r = append(r, v)
}
}

default: panic(f)
}
return r
}
Expand Down
13 changes: 11 additions & 2 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (s *ESlice) DeleteIf(f interface{}) {
}
}

default: p = len(a)
default: panic(f)
}
s.release_references(p, len(a) - p)
*s = a[:p]
Expand All @@ -113,6 +113,7 @@ func (s ESlice) Each(f interface{}) {
case func(interface{}): for _, v := range s { f(v) }
case func(int, interface{}): for i, v := range s { f(i, v) }
case func(interface{}, interface{}): for i, v := range s { f(i, v) }
default: panic(f)
}
}

Expand Down Expand Up @@ -148,6 +149,7 @@ func (s ESlice) While(f interface{}) int {
return i
}
}
default: panic(f)
}
return len(s)
}
Expand Down Expand Up @@ -184,6 +186,7 @@ func (s ESlice) Until(f interface{}) int {
return i
}
}
default: panic(f)
}
return len(s)
}
Expand Down Expand Up @@ -216,6 +219,7 @@ func (s ESlice) Overwrite(offset int, container interface{}) {
switch container := container.(type) {
case ESlice: copy(s[offset:], container)
case []error: copy(s[offset:], container)
default: panic(container)
}
}

Expand Down Expand Up @@ -525,7 +529,7 @@ func (s *ESlice) KeepIf(f interface{}) {
}
}

default: p = len(a)
default: panic(f)
}
s.release_references(p, len(a) - p)
*s = a[:p]
Expand All @@ -539,6 +543,7 @@ func (s ESlice) ReverseEach(f interface{}) {
case func(interface{}): for i := len(s) - 1; i > -1; i-- { f(s[i]) }
case func(int, interface{}): for i := len(s) - 1; i > -1; i-- { f(i, s[i]) }
case func(interface{}, interface{}): for i := len(s) - 1; i > -1; i-- { f(i, s[i]) }
default: panic(f)
}
}

Expand All @@ -562,6 +567,8 @@ func (s ESlice) ReplaceIf(f interface{}, r interface{}) {
s[i] = replacement
}
}

default: panic(f)
}
}

Expand Down Expand Up @@ -594,6 +601,8 @@ func (s ESlice) Select(f interface{}) interface{} {
r = append(r, v)
}
}

default: panic(f)
}
return r
}
Expand Down
13 changes: 11 additions & 2 deletions float32.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (s *F32Slice) DeleteIf(f interface{}) {
}
}

default: p = len(a)
default: panic(f)
}
*s = a[:p]
}
Expand All @@ -152,6 +152,7 @@ func (s F32Slice) Each(f interface{}) {
case func(interface{}): for _, v := range s { f(v) }
case func(int, interface{}): for i, v := range s { f(i, v) }
case func(interface{}, interface{}): for i, v := range s { f(i, v) }
default: panic(f)
}
}

Expand Down Expand Up @@ -187,6 +188,7 @@ func (s F32Slice) While(f interface{}) int {
return i
}
}
default: panic(f)
}
return len(s)
}
Expand Down Expand Up @@ -223,6 +225,7 @@ func (s F32Slice) Until(f interface{}) int {
return i
}
}
default: panic(f)
}
return len(s)
}
Expand Down Expand Up @@ -255,6 +258,7 @@ func (s F32Slice) Overwrite(offset int, container interface{}) {
switch container := container.(type) {
case F32Slice: copy(s[offset:], container)
case []float32: copy(s[offset:], container)
default: panic(container)
}
}

Expand Down Expand Up @@ -553,7 +557,7 @@ func (s *F32Slice) KeepIf(f interface{}) {
}
}

default: p = len(a)
default: panic(f)
}
*s = a[:p]
}
Expand All @@ -566,6 +570,7 @@ func (s F32Slice) ReverseEach(f interface{}) {
case func(interface{}): for i := len(s) - 1; i > -1; i-- { f(s[i]) }
case func(int, interface{}): for i := len(s) - 1; i > -1; i-- { f(i, s[i]) }
case func(interface{}, interface{}): for i := len(s) - 1; i > -1; i-- { f(i, s[i]) }
default: panic(f)
}
}

Expand All @@ -589,6 +594,8 @@ func (s F32Slice) ReplaceIf(f interface{}, r interface{}) {
s[i] = replacement
}
}

default: panic(f)
}
}

Expand Down Expand Up @@ -621,6 +628,8 @@ func (s F32Slice) Select(f interface{}) interface{} {
r = append(r, v)
}
}

default: panic(f)
}
return r
}
Expand Down
13 changes: 11 additions & 2 deletions float64.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (s *F64Slice) DeleteIf(f interface{}) {
}
}

default: p = len(a)
default: panic(f)
}
*s = a[:p]
}
Expand All @@ -152,6 +152,7 @@ func (s F64Slice) Each(f interface{}) {
case func(interface{}): for _, v := range s { f(v) }
case func(int, interface{}): for i, v := range s { f(i, v) }
case func(interface{}, interface{}): for i, v := range s { f(i, v) }
default: panic(f)
}
}

Expand Down Expand Up @@ -187,6 +188,7 @@ func (s F64Slice) While(f interface{}) int {
return i
}
}
default: panic(f)
}
return len(s)
}
Expand Down Expand Up @@ -223,6 +225,7 @@ func (s F64Slice) Until(f interface{}) int {
return i
}
}
default: panic(f)
}
return len(s)
}
Expand Down Expand Up @@ -255,6 +258,7 @@ func (s F64Slice) Overwrite(offset int, container interface{}) {
switch container := container.(type) {
case F64Slice: copy(s[offset:], container)
case []float64: copy(s[offset:], container)
default: panic(container)
}
}

Expand Down Expand Up @@ -553,7 +557,7 @@ func (s *F64Slice) KeepIf(f interface{}) {
}
}

default: p = len(a)
default: panic(f)
}
*s = a[:p]
}
Expand All @@ -566,6 +570,7 @@ func (s F64Slice) ReverseEach(f interface{}) {
case func(interface{}): for i := len(s) - 1; i > -1; i-- { f(s[i]) }
case func(int, interface{}): for i := len(s) - 1; i > -1; i-- { f(i, s[i]) }
case func(interface{}, interface{}): for i := len(s) - 1; i > -1; i-- { f(i, s[i]) }
default: panic(f)
}
}

Expand All @@ -589,6 +594,8 @@ func (s F64Slice) ReplaceIf(f interface{}, r interface{}) {
s[i] = replacement
}
}

default: panic(f)
}
}

Expand Down Expand Up @@ -621,6 +628,8 @@ func (s F64Slice) Select(f interface{}) interface{} {
r = append(r, v)
}
}

default: panic(f)
}
return r
}
Expand Down
Loading

0 comments on commit df81e03

Please sign in to comment.