From eb2aefdcdbfd53b364b04aed757eea1402514987 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 18 Feb 2015 21:33:03 +1100 Subject: [PATCH] internal/pieceordering: Doc --- internal/pieceordering/pieceordering.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/pieceordering/pieceordering.go b/internal/pieceordering/pieceordering.go index acf3cc0c..d26cbdcd 100644 --- a/internal/pieceordering/pieceordering.go +++ b/internal/pieceordering/pieceordering.go @@ -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 { -- 2.48.1