Skip to content

Commit

Permalink
Now formatting with gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
umpc committed Jul 4, 2017
1 parent 2b0b2aa commit c636819
Show file tree
Hide file tree
Showing 37 changed files with 76 additions and 75 deletions.
2 changes: 1 addition & 1 deletion asc/error.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package asc

const greaterThanErr = "the higher value was less than the lesser value!"
const greaterThanErr = "the higher value was less than the lesser value!"
2 changes: 1 addition & 1 deletion asc/numeric.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ func Uint(i, j interface{}) bool {

func Int(i, j interface{}) bool {
return i.(int) < j.(int)
}
}
2 changes: 1 addition & 1 deletion asc/numeric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ func TestInt(t *testing.T) {
if Int(int(1), 0) {
t.Fatal("asc.TestInt failed: %v", greaterThanErr)
}
}
}
2 changes: 1 addition & 1 deletion asc/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import "time"

func Time(i, j interface{}) bool {
return i.(time.Time).Before(j.(time.Time))
}
}
2 changes: 1 addition & 1 deletion asc/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ func TestTime(t *testing.T) {
if Time(laterDate, earlerDate) {
t.Fatal("asc.TestTime failed: laterDate was before earlierDate")
}
}
}
4 changes: 2 additions & 2 deletions bounds.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (sm *SortedMap) setBoundIdx(boundVal interface{}) int {

// If the bound value is greater than or equal to the value from the map,
// select the next index value.
if idx < smLen - 1 {
if idx < smLen-1 {
if sm.lessFn(valFromIdx, boundVal) {
idx++
}
Expand Down Expand Up @@ -60,4 +60,4 @@ func (sm *SortedMap) boundsIdxSearch(lowerBound, upperBound interface{}) []int {
lowerBoundIdx,
upperBoundIdx,
}
}
}
6 changes: 3 additions & 3 deletions delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (sm *SortedMap) delete(key interface{}) bool {

if i == smLen {
i--
} else if i < smLen - 1 {
} else if i < smLen-1 {
i++
}
for sm.sorted[i] != key {
Expand All @@ -32,7 +32,7 @@ func (sm *SortedMap) boundedDelete(lowerBound, upperBound interface{}) bool {
if iterBounds == nil {
return false
}
for i := iterBounds[0]; i <= iterBounds[1] - i; i++ {
for i := iterBounds[0]; i <= iterBounds[1]-i; i++ {
delete(sm.idx, sm.sorted[i])
sm.sorted = deleteInterface(sm.sorted, i)
}
Expand All @@ -58,4 +58,4 @@ func (sm *SortedMap) BatchDelete(keys []interface{}) []bool {
// BoundedDelete returns true if the operation was successful, or false otherwise.
func (sm *SortedMap) BoundedDelete(lowerBound, upperBound interface{}) bool {
return sm.boundedDelete(lowerBound, upperBound)
}
}
2 changes: 1 addition & 1 deletion delete_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ func BenchmarkBatchDelete1000of1000Records(b *testing.B) {

func BenchmarkBatchDelete10000of10000Records(b *testing.B) {
batchDeleteNofNRecords(b, 10000)
}
}
4 changes: 2 additions & 2 deletions delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestBatchDelete(t *testing.T) {

func TestBoundedDelete(t *testing.T) {
const (
nilBoundValsErr = "accepted nil bound value"
nilBoundValsErr = "accepted nil bound value"
generalBoundsErr = "general bounds error"
)

Expand Down Expand Up @@ -93,4 +93,4 @@ func TestBoundedDelete(t *testing.T) {
if err := verifyRecords(sm.IterCh(), false); err != nil {
t.Fatal(err)
}
}
}
2 changes: 1 addition & 1 deletion desc/error.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package desc

const greaterThanErr = "the lesser value was greater than the higher value!"
const greaterThanErr = "the lesser value was greater than the higher value!"
2 changes: 1 addition & 1 deletion desc/numeric.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ func Uint(i, j interface{}) bool {

func Int(i, j interface{}) bool {
return i.(int) > j.(int)
}
}
2 changes: 1 addition & 1 deletion desc/numeric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ func TestInt(t *testing.T) {
if Int(int(0), 0) {
t.Fatal("desc.TestInt failed: %v", greaterThanErr)
}
}
}
2 changes: 1 addition & 1 deletion desc/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import "time"

func Time(i, j interface{}) bool {
return i.(time.Time).After(j.(time.Time))
}
}
2 changes: 1 addition & 1 deletion desc/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ func TestTime(t *testing.T) {
if Time(earlerDate, laterDate) {
t.Fatal("desc.TestTime failed: earlierDate was after laterDate")
}
}
}
2 changes: 1 addition & 1 deletion get.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ func (sm *SortedMap) BatchGet(keys []interface{}) ([]interface{}, []bool) {
}

return vals, results
}
}
2 changes: 1 addition & 1 deletion get_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ func BenchmarkBatchGet1000of1000Records(b *testing.B) {

func BenchmarkBatchGet10000of10000Records(b *testing.B) {
batchGetNofNRecords(b, 10000)
}
}
2 changes: 1 addition & 1 deletion get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ func TestBatchGet(t *testing.T) {
if err := verifyRecords(sm.IterCh(), false); err != nil {
t.Fatal(err)
}
}
}
2 changes: 1 addition & 1 deletion has.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ func (sm *SortedMap) BatchHas(keys []interface{}) []bool {
_, results[i] = sm.idx[key]
}
return results
}
}
2 changes: 1 addition & 1 deletion has_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ func BenchmarkBatchHas1000of1000Records(b *testing.B) {

func BenchmarkBatchHas10000of10000Records(b *testing.B) {
batchHasNofNRecords(b, 10000)
}
}
2 changes: 1 addition & 1 deletion has_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ func TestBatchHas(t *testing.T) {
if err := verifyRecords(sm.IterCh(), false); err != nil {
t.Fatal(err)
}
}
}
4 changes: 2 additions & 2 deletions insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (sm *SortedMap) batchInsertMapStringKeys(m map[string]interface{}) error {

// BatchInsertMap adds all map keys and values to the collection.
// If a key already exists, the value will not be inserted and an error will be returned.
// Use BatchReplaceMap for the alternative functionality.
// Use BatchReplaceMap for the alternative functionality.
func (sm *SortedMap) BatchInsertMap(v interface{}) error {
const unsupportedTypeErr = "Unsupported type."

Expand All @@ -61,4 +61,4 @@ func (sm *SortedMap) BatchInsertMap(v interface{}) error {
default:
return fmt.Errorf("%s", unsupportedTypeErr)
}
}
}
2 changes: 1 addition & 1 deletion insert_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ func BenchmarkBatchInsert1000Records(b *testing.B) {

func BenchmarkBatchInsert10000Records(b *testing.B) {
batchInsertRecords(b, 10000)
}
}
4 changes: 2 additions & 2 deletions insert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ func TestBatchInsertMapWithExistingStringKeys(t *testing.T) {
}
}

func TestBatchInsertMapWithNilType(t *testing.T) {
func TestBatchInsertMapWithNilType(t *testing.T) {
if err := New(0, asc.Time).BatchInsertMap(nil); err == nil {
t.Fatal("a nil type was allowed where a supported map type is required.")
}
}
}
2 changes: 1 addition & 1 deletion insertsort.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ func (sm *SortedMap) insertSort(key, val interface{}) []interface{} {
return insertInterface(sm.sorted, key, sort.Search(len(sm.sorted), func(i int) bool {
return sm.lessFn(val, sm.idx[sm.sorted[i]])
}))
}
}
10 changes: 5 additions & 5 deletions iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import "time"
// channel send goroutines to time-out.
// BufSize is set to 1 if its field is set to a lower value.
// LowerBound and UpperBound default to regular iteration when left unset.
type IterChParams struct{
Reversed bool
type IterChParams struct {
Reversed bool
SendTimeout time.Duration
BufSize int
BufSize int
LowerBound,
UpperBound interface{}
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func (sm *SortedMap) IterCh() <-chan Record {
// This method defaults to the expected behavior of blocking until a channel send completes, with no timeout.
func (sm *SortedMap) BoundedIterCh(reversed bool, lowerBound, upperBound interface{}) (<-chan Record, bool) {
return sm.iterCh(IterChParams{
Reversed: reversed,
Reversed: reversed,
LowerBound: lowerBound,
UpperBound: upperBound,
})
Expand All @@ -143,4 +143,4 @@ func (sm *SortedMap) IterFunc(reversed bool, f IterCallbackFunc) {
// Sort order is reversed if the reversed argument is set to true.
func (sm *SortedMap) BoundedIterFunc(reversed bool, lowerBound, upperBound interface{}, f IterCallbackFunc) bool {
return sm.iterFunc(reversed, lowerBound, upperBound, f)
}
}
38 changes: 19 additions & 19 deletions iter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
)

const (
nilBoundValsErr = "accepted nil bound values"
nilBoundValsErr = "accepted nil bound values"
generalBoundsErr = "between bounds error"
nilValErr = "nil value!"
nonNilValErr = "non-nil value"
runawayIterErr = "runaway iterator!"
nilValErr = "nil value!"
nonNilValErr = "non-nil value"
runawayIterErr = "runaway iterator!"
)

var maxTime = time.Unix(1<<63 - 62135596801, 999999999)
var maxTime = time.Unix(1<<63-62135596801, 999999999)

func TestIterCh(t *testing.T) {
if _, _, err := newSortedMapFromRandRecords(1000); err != nil {
Expand All @@ -33,7 +33,7 @@ func TestIterChTimeout(t *testing.T) {
if ch, ok := sm.CustomIterCh(params); ok {
for i := 0; i < 5; i++ {
time.Sleep(sleepDur)
rec := <- ch
rec := <-ch
if i > 1 && rec.Key != nil {
t.Fatalf("TestIterChTimeout failed: %v: %v", nonNilValErr, rec.Key)
}
Expand All @@ -48,7 +48,7 @@ func TestIterChTimeout(t *testing.T) {
if ch, ok := sm.CustomIterCh(params); ok {
for i := 0; i < 5; i++ {
time.Sleep(sleepDur)
rec := <- ch
rec := <-ch
if i > 1 && rec.Key != nil {
t.Fatalf("TestIterChTimeout failed: %v: %v", nonNilValErr, rec.Key)
}
Expand All @@ -58,13 +58,13 @@ func TestIterChTimeout(t *testing.T) {
}

params = IterChParams{
Reversed: true,
Reversed: true,
SendTimeout: timeout,
}
if ch, ok := sm.CustomIterCh(params); ok {
for i := 0; i < 5; i++ {
time.Sleep(sleepDur)
rec := <- ch
rec := <-ch
if i > 1 && rec.Key != nil {
t.Fatalf("TestIterChTimeout failed: %v: %v", nonNilValErr, rec.Key)
}
Expand All @@ -79,7 +79,7 @@ func TestIterChTimeout(t *testing.T) {
if ch, ok := sm.CustomIterCh(params); ok {
for i := 0; i < 5; i++ {
time.Sleep(sleepDur)
rec := <- ch
rec := <-ch
if i > 1 && rec.Key != nil {
t.Fatalf("TestIterChTimeout failed: %v: %v", nonNilValErr, rec.Key)
}
Expand Down Expand Up @@ -154,7 +154,7 @@ func TestBoundedIterCh(t *testing.T) {

func TestCustomIterCh(t *testing.T) {
const (
nilBoundValsErr = "accepted two nil bound values"
nilBoundValsErr = "accepted two nil bound values"
generalBoundsErr = "only one bound value"
)
sm, _, err := newSortedMapFromRandRecords(1000)
Expand All @@ -170,7 +170,7 @@ func TestCustomIterCh(t *testing.T) {

params := IterChParams{
Reversed: reversed,
BufSize: buffSize,
BufSize: buffSize,
}

if ch, ok := sm.CustomIterCh(params); ok {
Expand All @@ -182,8 +182,8 @@ func TestCustomIterCh(t *testing.T) {
}

params = IterChParams{
Reversed: reversed,
BufSize: buffSize,
Reversed: reversed,
BufSize: buffSize,
LowerBound: earlierDate,
UpperBound: laterDate,
}
Expand All @@ -197,8 +197,8 @@ func TestCustomIterCh(t *testing.T) {
}

params = IterChParams{
Reversed: reversed,
BufSize: buffSize,
Reversed: reversed,
BufSize: buffSize,
LowerBound: laterDate,
UpperBound: earlierDate,
}
Expand All @@ -213,8 +213,8 @@ func TestCustomIterCh(t *testing.T) {

reversed = false
params = IterChParams{
Reversed: reversed,
BufSize: 0,
Reversed: reversed,
BufSize: 0,
LowerBound: laterDate,
UpperBound: earlierDate,
}
Expand Down Expand Up @@ -370,4 +370,4 @@ func TestBoundedIterFunc(t *testing.T) {
}); ok {
t.Fatalf("TestBoundedIterFunc failed: %v", nilValErr)
}
}
}
4 changes: 2 additions & 2 deletions keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ func (sm *SortedMap) keys(lowerBound, upperBound interface{}) ([]interface{}, bo
if idxBounds == nil {
return nil, false
}
return sm.sorted[idxBounds[0]:idxBounds[1] + 1], true
return sm.sorted[idxBounds[0] : idxBounds[1]+1], true
}

// Keys returns a slice containing sorted keys.
Expand All @@ -19,4 +19,4 @@ func (sm *SortedMap) Keys() []interface{} {
// The returned slice is valid until the next modification to the SortedMap structure.
func (sm *SortedMap) BoundedKeys(lowerBound, upperBound interface{}) ([]interface{}, bool) {
return sm.keys(lowerBound, upperBound)
}
}
4 changes: 2 additions & 2 deletions keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestBoundedKeysWithNoBoundsReturned(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if val, ok := sm.BoundedKeys(time.Now().Add(-1 * time.Microsecond), time.Now()); ok {
if val, ok := sm.BoundedKeys(time.Now().Add(-1*time.Microsecond), time.Now()); ok {
t.Fatalf("Values fall between or are equal to the given bounds when it should not have returned bounds: %+v", sm.idx[val[0]])
}
}
}
Loading

0 comments on commit c636819

Please sign in to comment.