Skip to content

Commit 0531fcb

Browse files
authored
#3 - optimize comfyCmpMap count values; update docs (#17)
1 parent 197498c commit 0531fcb

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

README.adoc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
= What is Comfy Gopher?
1+
= Comfy Gopher - Collections
2+
3+
image:https://codecov.io/gh/comfygopher/collections/graph/badge.svg?token=I5QQ2SU3E7[codecov,link=https://codecov.io/gh/comfygopher/collections]
4+
5+
image:https://img.shields.io/coderabbit/prs/github/comfygopher/collections?utm_source=oss&utm_medium=github&utm_campaign=comfygopher%2Fcollections&labelColor=171717&color=FF570A&link=https%3A%2F%2Fcoderabbit.ai&label=CodeRabbit+Reviews[CodeRabbit Pull Request Reviews]
6+
7+
== What is Comfy Gopher?
28

39
*Comfy Gopher is a Set of general-purpose Tools, Utilities, and Data Structures for Comfortable Development*
410

511
These tools prioritize speed and ease of development over strict efficiency or full compliance with Go philosophy.
612
They accelerate development and enhance the experience, by reducing the cognitive load,
713
making them well suited for rapid prototyping.
814

9-
== Comfy Gopher - Collections
15+
== Comfy Gopher - Collections package
1016

1117
=== Goals
1218

1319
1. Provide convenient abstraction for collection data structures
20+
1. Focus on developer experience
1421
1. Reduce repetition in day-to-day collections operations
1522
1. Address the missing ordered map data structure
1623
1. Provide API for in-place modifications of collections

mapcmp.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,15 @@ func (c *comfyCmpMap[K, V]) Contains(predicate Predicate[Pair[K, V]]) bool {
8989
}
9090

9191
func (c *comfyCmpMap[K, V]) ContainsValue(v V) bool {
92-
return comfyContains[Base[Pair[K, V]], Pair[K, V]](c, func(_ int, pair Pair[K, V]) bool {
93-
return pair.Val() == v
94-
})
92+
return c.vc.Count(v) > 0
9593
}
9694

9795
func (c *comfyCmpMap[K, V]) Count(predicate Predicate[Pair[K, V]]) int {
9896
return comfyCount[Indexed[Pair[K, V]], Pair[K, V]](c, predicate)
9997
}
10098

10199
func (c *comfyCmpMap[K, V]) CountValues(v V) int {
102-
return comfyCount[Indexed[Pair[K, V]], Pair[K, V]](c, func(_ int, pair Pair[K, V]) bool {
103-
return pair.Val() == v
104-
})
100+
return c.vc.Count(v)
105101
}
106102

107103
func (c *comfyCmpMap[K, V]) Each(f Visitor[Pair[K, V]]) {

0 commit comments

Comments
 (0)