Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dictionary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
},
Expand Down
11 changes: 3 additions & 8 deletions filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -75,4 +71,3 @@ func (d Directory) Enumerate(ctx context.Context) Enumerator[string] {

return results
}

4 changes: 2 additions & 2 deletions linkedlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions lru_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions query_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
Expand Down Expand Up @@ -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
})
Expand Down
2 changes: 1 addition & 1 deletion query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down