mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Implements the kmeans++ algo to select the landmarks in the geometric method
Former-commit-id: 732404a0dc6d7276e4e479dd2481aa4bd42d4ce5
This commit is contained in:
@ -31,7 +31,7 @@ func NewBioSequenceSlice(size ...int) *BioSequenceSlice {
|
||||
slice := _BioSequenceSlicePool.Get().(*BioSequenceSlice)
|
||||
if len(size) > 0 {
|
||||
s := size[0]
|
||||
slice = slice.InsureCapacity(s)
|
||||
slice = slice.EnsureCapacity(s)
|
||||
(*slice) = (*slice)[0:s]
|
||||
}
|
||||
return slice
|
||||
@ -76,11 +76,11 @@ func (s *BioSequenceSlice) Recycle(including_seq bool) {
|
||||
_BioSequenceSlicePool.Put(s)
|
||||
}
|
||||
|
||||
// InsureCapacity ensures that the BioSequenceSlice has a minimum capacity
|
||||
// EnsureCapacity ensures that the BioSequenceSlice has a minimum capacity
|
||||
//
|
||||
// It takes an integer `capacity` as a parameter, which represents the desired minimum capacity of the BioSequenceSlice.
|
||||
// It returns a pointer to the BioSequenceSlice.
|
||||
func (s *BioSequenceSlice) InsureCapacity(capacity int) *BioSequenceSlice {
|
||||
func (s *BioSequenceSlice) EnsureCapacity(capacity int) *BioSequenceSlice {
|
||||
var c int
|
||||
if s != nil {
|
||||
c = cap(*s)
|
||||
@ -88,7 +88,9 @@ func (s *BioSequenceSlice) InsureCapacity(capacity int) *BioSequenceSlice {
|
||||
c = 0
|
||||
}
|
||||
|
||||
*s = slices.Grow[BioSequenceSlice](*s, capacity-c)
|
||||
if capacity > c {
|
||||
*s = slices.Grow[BioSequenceSlice](*s, capacity-c)
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
Reference in New Issue
Block a user