Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generics を用いた抽象化セグ木のプロトタイプ実装 #31

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

monkukui
Copy link
Owner

@monkukui monkukui commented Dec 15, 2021

Ramge Maxima Query の場合

- a := make([]interface{}, n)
+ a := make([]int, n)
for i := 0; i < n; i++ {
	a[i] = io.NextInt()
}
- op := func(a, b interface{}) interface{} {
+ op := func(a, b int) int {
- 	aa, _ := a.(int)
- 	bb, _ := b.(int)
	if aa > bb {
		return aa
	}
	return bb
}
- e := func() interface{} {
+ e := func() int {
	return -1
}
- seg := NewBySlice(op, e, a)
+ seg := NewBySlice[int](op, e, a)

@monkukui monkukui requested a review from nu50218 as a code owner December 15, 2021 06:46
@@ -4,29 +4,30 @@ import (
internal "github.com/monkukui/ac-library-go/internal/bit"
)

type SegTree struct {
type SegTree[T any] struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
expected ']', found any (typecheck)

@monkukui monkukui marked this pull request as draft December 15, 2021 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant