mirror of https://github.com/v2ray/v2ray-core
update RecivingWindow.Remove
parent
7f661f5215
commit
231f5fc140
|
@ -33,9 +33,6 @@ func (this *ReceivingWindow) Set(idx uint32, value *Segment) bool {
|
||||||
|
|
||||||
func (this *ReceivingWindow) Remove(idx uint32) *Segment {
|
func (this *ReceivingWindow) Remove(idx uint32) *Segment {
|
||||||
pos := this.Position(idx)
|
pos := this.Position(idx)
|
||||||
if this.list[pos] == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
e := this.list[pos]
|
e := this.list[pos]
|
||||||
this.list[pos] = nil
|
this.list[pos] = nil
|
||||||
return e
|
return e
|
||||||
|
|
|
@ -19,6 +19,10 @@ func TestRecivingWindow(t *testing.T) {
|
||||||
|
|
||||||
assert.Bool(window.Set(0, seg0)).IsTrue()
|
assert.Bool(window.Set(0, seg0)).IsTrue()
|
||||||
assert.Pointer(window.RemoveFirst()).Equals(seg0)
|
assert.Pointer(window.RemoveFirst()).Equals(seg0)
|
||||||
|
e := window.RemoveFirst()
|
||||||
|
if e != nil {
|
||||||
|
assert.Fail("Expecting nil.")
|
||||||
|
}
|
||||||
|
|
||||||
assert.Bool(window.Set(1, seg1)).IsTrue()
|
assert.Bool(window.Set(1, seg1)).IsTrue()
|
||||||
assert.Bool(window.Set(2, seg2)).IsTrue()
|
assert.Bool(window.Set(2, seg2)).IsTrue()
|
||||||
|
|
Loading…
Reference in New Issue