Based on QuantumNous/new-api v1.0.0-rc.36 (shallow history squashed). - CNY quota display mode: RMB-denominated top-up and crediting across Epay/Waffo channels - New CheckinButton in both authenticated and public headers (Turnstile supported) - New /subscribe page with public plan snapshot, Alipay/balance payment, auto group upgrade/reset - New /docs 12-section beginner guide with anchor navigation - New home PromoBanner linking to /docs; i18n synced (en/zh/zh-TW/fr/ja/ru/vi) - README: document custom features, live demo https://ai.88531.cn
37 lines
567 B
Go
37 lines
567 B
Go
package types
|
|
|
|
type Set[T comparable] struct {
|
|
items map[T]struct{}
|
|
}
|
|
|
|
func NewSet[T comparable]() *Set[T] {
|
|
return &Set[T]{
|
|
items: make(map[T]struct{}),
|
|
}
|
|
}
|
|
|
|
func (s *Set[T]) Add(item T) {
|
|
s.items[item] = struct{}{}
|
|
}
|
|
|
|
func (s *Set[T]) Remove(item T) {
|
|
delete(s.items, item)
|
|
}
|
|
|
|
func (s *Set[T]) Contains(item T) bool {
|
|
_, exists := s.items[item]
|
|
return exists
|
|
}
|
|
|
|
func (s *Set[T]) Len() int {
|
|
return len(s.items)
|
|
}
|
|
|
|
func (s *Set[T]) Items() []T {
|
|
items := make([]T, 0, s.Len())
|
|
for item := range s.items {
|
|
items = append(items, item)
|
|
}
|
|
return items
|
|
}
|