...

Source file src/github.com/Masterminds/semver/v3/collection.go

Documentation: github.com/Masterminds/semver/v3

     1  package semver
     2  
     3  // Collection is a collection of Version instances and implements the sort
     4  // interface. See the sort package for more details.
     5  // https://golang.org/pkg/sort/
     6  type Collection []*Version
     7  
     8  // Len returns the length of a collection. The number of Version instances
     9  // on the slice.
    10  func (c Collection) Len() int {
    11  	return len(c)
    12  }
    13  
    14  // Less is needed for the sort interface to compare two Version objects on the
    15  // slice. If checks if one is less than the other.
    16  func (c Collection) Less(i, j int) bool {
    17  	return c[i].LessThan(c[j])
    18  }
    19  
    20  // Swap is needed for the sort interface to replace the Version objects
    21  // at two different positions in the slice.
    22  func (c Collection) Swap(i, j int) {
    23  	c[i], c[j] = c[j], c[i]
    24  }
    25  

View as plain text