filechunks.go 433 B

1234567891011121314151617181920212223
  1. package filer2
  2. type Chunks []FileChunk
  3. func (chunks Chunks) TotalSize() (size uint64) {
  4. for _, c := range chunks {
  5. t := uint64(c.Offset + int64(c.Size))
  6. if size < t {
  7. size = t
  8. }
  9. }
  10. return
  11. }
  12. func (chunks Chunks) Len() int {
  13. return len(chunks)
  14. }
  15. func (chunks Chunks) Swap(i, j int) {
  16. chunks[i], chunks[j] = chunks[j], chunks[i]
  17. }
  18. func (chunks Chunks) Less(i, j int) bool {
  19. return chunks[i].Offset < chunks[j].Offset
  20. }