diff --git a/.gitattributes b/.gitattributes index 581182ba21..1629521d89 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18458,6 +18458,7 @@ tests/webtbs/tw37322.pp svneol=native#text/pascal tests/webtbs/tw37323.pp svneol=native#text/pascal tests/webtbs/tw37339.pp svneol=native#text/pascal tests/webtbs/tw37355.pp svneol=native#text/pascal +tests/webtbs/tw37382.pp svneol=native#text/pascal tests/webtbs/tw37393.pp svneol=native#text/pascal tests/webtbs/tw37397.pp svneol=native#text/plain tests/webtbs/tw37398.pp svneol=native#text/pascal diff --git a/packages/fcl-stl/src/gdeque.pp b/packages/fcl-stl/src/gdeque.pp index 529098727b..c620188000 100644 --- a/packages/fcl-stl/src/gdeque.pp +++ b/packages/fcl-stl/src/gdeque.pp @@ -19,10 +19,10 @@ interface type generic TDeque=class private - type + type PT=^T; TArr=array of T; - var + var FData:TArr; FDataSize:SizeUInt; FCapacity:SizeUInt; @@ -77,7 +77,7 @@ end; procedure TDeque.PushBack(value:T);inline; begin - if(FDataSize=FCapacity) then + if(FDataSize=FCapacity) then IncreaseCapacity; FData[(FStart+FDataSize)mod FCapacity]:=value; inc(FDataSize); @@ -85,11 +85,11 @@ end; procedure TDeque.PopFront();inline; begin - if(FDataSize>0) then + if(FDataSize>0) then begin inc(FStart); dec(FDataSize); - if(FStart=FCapacity) then + if(FStart=FCapacity) then FStart:=0; end; end; @@ -167,7 +167,7 @@ begin FCapacity:=FCapacity+FCapacity div 16; SetLength(FData, FCapacity); - if (FStart>0) then + if (FStart>0) then for i:=0 to FStart-1 do FData[OldEnd+i]:=FData[i]; end; @@ -175,11 +175,11 @@ end; procedure TDeque.Reserve(cap:SizeUInt);inline; var i,OldEnd:SizeUInt; begin - if(cap 1 then + for i:=Position to Size-2 do + begin + Items[i]:=Items[i+1]; + end; popBack(); end; end; diff --git a/tests/webtbs/tw37382.pp b/tests/webtbs/tw37382.pp new file mode 100644 index 0000000000..708298f73e --- /dev/null +++ b/tests/webtbs/tw37382.pp @@ -0,0 +1,20 @@ +{$mode objfpc} +{$h+} + +uses + GDeque; + +type + TIntQueue = specialize TDeque; + +var + Q: TIntQueue; + +begin + Q := TIntQueue.Create; + Q.Insert(0, 12345); + writeln('Size=',Q.Size); + Q.Erase(0); + writeln('Size=',Q.Size); + Q.Free; +end.