diff --git a/dictionary_test.go b/dictionary_test.go index 5184eea..7b5807d 100644 --- a/dictionary_test.go +++ b/dictionary_test.go @@ -40,9 +40,9 @@ func TestDictionary_Enumerate(t *testing.T) { prev := "" for result := range subject.Enumerate(context.Background()) { - t.Logf(result) + t.Log(result) if alreadySeen, ok := expected[result]; !ok { - t.Logf("An unadded value was returned") + t.Log("An unadded value was returned") t.Fail() } else if alreadySeen { t.Logf("\"%s\" was duplicated", result) @@ -92,9 +92,9 @@ func TestTrieNode_Navigate(t *testing.T) { } subject := trieNode{ Children: map[rune]*trieNode{ - 'a': &trieNode{ + 'a': { Children: map[rune]*trieNode{ - 'b': &trieNode{ + 'b': { Children: map[rune]*trieNode{ 'c': &leaf, }, diff --git a/filesystem.go b/filesystem.go index c1c4d20..1fb239d 100644 --- a/filesystem.go +++ b/filesystem.go @@ -23,16 +23,12 @@ type Directory struct { Options DirectoryOptions } -func defaultEnumeratePredicate(loc string, info os.FileInfo) bool { - return true -} - func (d Directory) applyOptions(loc string, info os.FileInfo) bool { - if info.IsDir() && 0 != (d.Options&DirectoryOptionsExcludeDirectories) { + if info.IsDir() && (d.Options&DirectoryOptionsExcludeDirectories) != 0 { return false } - if !info.IsDir() && 0 != d.Options&DirectoryOptionsExcludeFiles { + if !info.IsDir() && d.Options&DirectoryOptionsExcludeFiles != 0 { return false } @@ -56,7 +52,7 @@ func (d Directory) Enumerate(ctx context.Context) Enumerator[string] { return } - if info.IsDir() && 0 == d.Options&DirectoryOptionsRecursive { + if info.IsDir() && d.Options&DirectoryOptionsRecursive == 0 { err = filepath.SkipDir } @@ -75,4 +71,3 @@ func (d Directory) Enumerate(ctx context.Context) Enumerator[string] { return results } - diff --git a/linkedlist.go b/linkedlist.go index 42c23ff..c43e597 100644 --- a/linkedlist.go +++ b/linkedlist.go @@ -110,7 +110,7 @@ func (list *LinkedList[T]) Enumerate(ctx context.Context) Enumerator[T] { for current != nil { select { case retval <- current.payload: - break + // Intentionally Left Blank case <-ctx.Done(): return } @@ -185,7 +185,7 @@ func (list *LinkedList[T]) RemoveFront() (T, bool) { list.first = list.first.next list.length-- - if 0 == list.length { + if list.length == 0 { list.last = nil } diff --git a/list.go b/list.go index b4a4f40..f1fb15a 100644 --- a/list.go +++ b/list.go @@ -50,7 +50,7 @@ func (l *List[T]) Enumerate(ctx context.Context) Enumerator[T] { for _, entry := range l.underlyer { select { case retval <- entry: - break + // Intentionally Left Blank case <-ctx.Done(): return } @@ -77,7 +77,7 @@ func (l *List[T]) Get(pos uint) (T, bool) { func (l *List[T]) IsEmpty() bool { l.key.RLock() defer l.key.RUnlock() - return 0 == len(l.underlyer) + return len(l.underlyer) == 0 } // Length returns the number of elements in the List. diff --git a/lru_cache.go b/lru_cache.go index 2e68797..393c829 100644 --- a/lru_cache.go +++ b/lru_cache.go @@ -101,7 +101,7 @@ func (lru *LRUCache[K, V]) Enumerate(ctx context.Context) Enumerator[V] { for entry := range nested { select { case retval <- entry.Value: - break + // Intentionally Left Blank case <-ctx.Done(): return } @@ -125,7 +125,7 @@ func (lru *LRUCache[K, V]) EnumerateKeys(ctx context.Context) Enumerator[K] { for entry := range nested { select { case retval <- entry.Key: - break + // Intentionally Left Blank case <-ctx.Done(): return } diff --git a/query.go b/query.go index 997eb31..22a5d5d 100644 --- a/query.go +++ b/query.go @@ -113,7 +113,7 @@ func (f EnumerableSlice[T]) Enumerate(ctx context.Context) Enumerator[T] { for _, entry := range f { select { case results <- entry: - break + // Intentionally Left Blank case <-ctx.Done(): return } @@ -509,7 +509,7 @@ func (iter Enumerator[T]) Skip(n uint) Enumerator[T] { // splitN creates N Enumerators, each will be a subset of the original Enumerator and will have // distinct populations from one another. func splitN[T any, E any](iter Enumerator[T], operation Transform[T, E], n uint) []Enumerator[E] { - results, cast := make([]chan E, n, n), make([]Enumerator[E], n, n) + results, cast := make([]chan E, n), make([]Enumerator[E], n) for i := uint(0); i < n; i++ { results[i] = make(chan E) diff --git a/query_examples_test.go b/query_examples_test.go index 91453ee..34bf2ea 100644 --- a/query_examples_test.go +++ b/query_examples_test.go @@ -138,27 +138,27 @@ func ExampleSelectMany() { breweries := collection.AsEnumerable( BrewHouse{ "Mac & Jacks", - collection.AsEnumerable[string]( + collection.AsEnumerable( "African Amber", "Ibis IPA", ), }, BrewHouse{ "Post Doc", - collection.AsEnumerable[string]( + collection.AsEnumerable( "Prereq Pale", ), }, BrewHouse{ "Resonate", - collection.AsEnumerable[string]( + collection.AsEnumerable( "Comfortably Numb IPA", "Lithium Altbier", ), }, BrewHouse{ "Triplehorn", - collection.AsEnumerable[string]( + collection.AsEnumerable( "Samson", "Pepper Belly", ), @@ -311,7 +311,7 @@ func ExampleEnumerator_Tee() { func ExampleUCount() { subject := collection.NewStack[any](9, 'a', "str1") - result := collection.UCount[any](subject, func(a interface{}) bool { + result := collection.UCount[interface{}](subject, func(a interface{}) bool { _, ok := a.(string) return ok }) diff --git a/query_test.go b/query_test.go index 9711440..655c7bd 100644 --- a/query_test.go +++ b/query_test.go @@ -47,7 +47,7 @@ func sleepIdentity[T any](val T) T { } func getInitializedSequentialArray[T ~int]() []T { - rawNums := make([]T, 1000, 1000) + rawNums := make([]T, 1000) for i := range rawNums { rawNums[i] = T(i + 1) }