github.com/searKing/golang/go@v1.2.74/util/spliterator/empty_spliterator.go (about)

     1  // Copyright 2020 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package spliterator
     6  
     7  import (
     8  	"context"
     9  
    10  	"github.com/searKing/golang/go/util/function/consumer"
    11  	"github.com/searKing/golang/go/util/object"
    12  )
    13  
    14  type EmptySpliterator struct {
    15  	TODO
    16  }
    17  
    18  func NewEmptySpliterator() *EmptySpliterator {
    19  	split := &EmptySpliterator{}
    20  	split.SetDerived(split)
    21  	return split
    22  }
    23  
    24  // Helper
    25  func (split *EmptySpliterator) follow() Spliterator {
    26  	derived := split.GetDerived()
    27  	if derived == nil {
    28  		return split
    29  	}
    30  	return derived.(Spliterator)
    31  }
    32  
    33  func (split *EmptySpliterator) TrySplit() Spliterator {
    34  	return nil
    35  }
    36  
    37  func (split *EmptySpliterator) TryAdvance(ctx context.Context, consumer consumer.Consumer) bool {
    38  	object.RequireNonNil(consumer)
    39  	return false
    40  }
    41  
    42  func (split *EmptySpliterator) ForEachRemaining(ctx context.Context, consumer consumer.Consumer) {
    43  	object.RequireNonNil(consumer)
    44  }
    45  
    46  func (split *EmptySpliterator) EstimateSize() int {
    47  	return 0
    48  }
    49  
    50  func (split *EmptySpliterator) Characteristics() Characteristic {
    51  	return CharacteristicSized | CharacteristicSubsized
    52  }