meian / gcf Goto Github PK
View Code? Open in Web Editor NEWA collection framework that supports generics on golang.
License: MIT License
A collection framework that supports generics on golang.
License: MIT License
Lines 18 to 20 in de7836c
この書き方をしている場合、引数の itb にnilを渡すと emptyIterable を返すので処理が軽いが、その次に他の関数を適用したときに empty ではなくなるので空の時にも処理が軽くならない
itb := gcf.Filter[int](nil, func(v int) bool { return v > 10}) // この時点では itb は empty
itb = gcf.Filter(itb, func(v int) bool { return v%2 == 0}) // この時点では itb は filterIterable だが要素は1件も取得できない
そのため以下のように修正することで emptyIterable をチェーンできるようにする
func SomeFunc[T any](itb Iterable[T]) Iterable[T] {
if isEmpty(itb) {
return orEmpty(itb)
}
....
}
こうすることで empty に対する処理に対して常に empty を返せるので、空の処理の場合に負荷がかからなくなる
itb := gcf.Filter[int](nil, func(v int) bool { return v > 10}) // この時点では itb は empty
itb = gcf.Filter(itb, func(v int) bool { return v%2 == 0}) // empty に対する処理なので empty になる
#5 対応後に Renovate入れる
とりあえずはデフォルト設定で良さそう
=> あまり設定いじる必要ないのでdependabotで試してみる
The README description is still old, so update it.
In addition, ensure that it works with newer go version.
Add any other context about the proposal here.
golang:1.18のGA出た後にdev containerのイメージを変更する。
後でrenovate入れるので、リビジョンとOSまで指定しておくこと
SkipLast
は件数を指定して末尾から除外するSkipLastWhile
は条件を指定して末尾から一致する範囲を除外するある程度整理したら0.0系でライブラリのバージョンを上げてリリース作る。
0.1とかはCI作ってからで良いかな多分
Add linter CI.
As a candidate, https://github.com/reviewdog/action-golangci-lint
Process static review on CI.
Originally posted by @meian in #3 (comment)
BenchmarkFilterとBenchmarkOnLoopのallocとかが繰り返しに比例していない?
関数ネストで複雑化しているところでバグってる可能性あるので全部個別に実装してみる
READMEにdescriptionとインストール方法以外書いてないので、以下の辺りを書くこと。
for it.MoveNext() { v := it.Current() }
になるのでどちらも同じといえば同じだけどTake
は件数を指定して先頭から取得するTakeWhile
は条件を指定して先頭から一致する範囲を取得するGithub Actionsで以下の辺り?
RCのイメージ使ってできるかも一応確認、ダメなら正規イメージ出てから
TODO: write later.
Describe the feature name and how feature processes.
Describe a clear and concise what achive from the feature.
We also welcome to post how to use example code.
Describe whether you can achive you want in already implemented another features.
Describe how loss with using another, also.
Add any other context about the feature request here.
Codecov整理して使えるようにする
やり方覚えてなくて大変そうなので #3 から切り出して後付で対応する
Iterator.MoveNext()
の条件分岐の書き方に揺れがあるので統一する
if it.it.MoveNext() {
it.current = it.it.Current()
return true
}
it.current = zero[T]()
return false
となっているところがあるので、
if !it.it.MoveNext() {
it.current = zero[T]()
return false
}
it.current = it.it.Current()
return true
になるように合わせる。
ただしforの利用や複数の条件分岐などで記述が複雑になる場合はそのまま残しておく
Last
は件数を指定して末尾から取得するLastWhile
は条件を指定して末尾から一致する範囲を取得するTakeWhileに渡す関数がnilの場合はTakeする条件が常にfalseなので空のIterableを返すように変更する
実装済のそれぞれの機能についてExample用意する
Reserach whether needs implement or not Iterator common fields.
By implementing some functions, I noticed Iterator has some common items.
If these are defined common struct, Iterator implement is simplify a little.
But, nested struct performance cost is not confirmed, so take benchmark for comparing using struct or not using.
Like strings.Repeat, change so func ends with panic by invalid zero or negative arguments.
Breaking change targets are below.
Understand easily for arguments ristriction and can approach to golang standard.
Skip
は件数を指定して先頭から除外するSkipWhile
は条件を指定して先頭から一致する範囲を除外する単語間違えてたのでまとめて直す _(:3」∠)_
Pull Requestを作るときに必要な確認項目をまとめたテンプレートを追加する。
そのうち種類ごとに分けるかもしれないけどまずは1テンプレート作ってみる。
Pull Requestを作る際に記述してほしい事、確認してほしい事を提示できる。
In other collection frameworks, function name that returns last n elements is TakeLast
.
To easier understand from function name.
Verify for introduce Block fixup commit merge.
Prevents merge before squash with fixup commits.
初期に出した実装はinterfaceとsliceしかコメント書いてないので、他のexportedな関数にコメントつける
Note: 後から追加の機能はここで対応するのでなく個別のチケット内で書くようにする
Repeat
は要素と件数を指定して同じ要素を繰り返して返すRepeat
は RepeatIteratable
に変更するAdd common test case for empty element but no emptyIterable.
The test checks for no panic.
Use test source like below.
itb := gcf.FromSlice([]int{1})
itb = gcf.Filter(itb, func(v int) bool { return false })
Since each Iterator does not expect to pass 0 Iterators, it could panic trying to process 0 Iterators.
By passing this test prevent that panic.
emptyじゃない時にパニック起こさない汎用のテストケース作ってソース以外の関数に適用する
Originally posted by @meian in #83 (comment)
[![Go Reference](https://pkg.go.dev/badge/github.com/meian/gcf.svg)](https://pkg.go.dev/github.com/meian/gcf)
Have easy access to standard reference.
Issue立てるときのテンプレートを作成する。
これ以降はなるべくテンプレートに従ったIssueの書き方にする。
最初はこのぐらいあればよいかな。
Iteratorの処理についてはスレッドセーフを考慮しない作りになっているのでその辺りをREADMEに追記する
Apply Go Report Card in CI.
Ensuring a certain level of code quality by various static analyzes.
ソート関連の実装
SortBy[T any, K Ordered](itb Iteratable[T], f func(T) K)
辺りのシグネチャで実装するイメージA declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.