]> Sergey Matveev's repositories - btrtrc.git/commitdiff
internal/pieceordering: Doc
authorMatt Joiner <anacrolix@gmail.com>
Wed, 18 Feb 2015 10:33:03 +0000 (21:33 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 18 Feb 2015 10:33:03 +0000 (21:33 +1100)
internal/pieceordering/pieceordering.go

index acf3cc0cacf3ff7a6b98b3eb637a688ea67acedc..d26cbdcd2d1b55ae09254be760e74fc1d08e48a8 100644 (file)
@@ -1,3 +1,5 @@
+// Implements ordering of torrent piece indices for such purposes as download
+// prioritization.
 package pieceordering
 
 import (
@@ -6,6 +8,7 @@ import (
        "github.com/ryszard/goskiplist/skiplist"
 )
 
+// Maintains piece integers by their ascending assigned keys.
 type Instance struct {
        sl        *skiplist.SkipList
        pieceKeys map[int]int
@@ -17,8 +20,8 @@ func New() *Instance {
        }
 }
 
-// Add the piece with the given key. No other piece can have the same key. If
-// the piece is already present, change its key.
+// Add the piece with the given key. If the piece is already present, change
+// its key.
 func (me *Instance) SetPiece(piece, key int) {
        if existingKey, ok := me.pieceKeys[piece]; ok {
                if existingKey == key {
@@ -80,6 +83,7 @@ func (me *Instance) DeletePiece(piece int) {
        delete(me.pieceKeys, piece)
 }
 
+// Returns the piece with the lowest key.
 func (me Instance) First() Element {
        i := me.sl.SeekToFirst()
        if i == nil {