View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006637 | JEDI Code Library | JclQueues | public | 2018-06-05 09:57 | 2018-06-05 09:57 |
Reporter | virgoparna | Assigned To | |||
Priority | normal | Severity | major | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | |||||
Target Version | Fixed in Version | ||||
Summary | 0006637: JclQueue classes can have maximum capacity - 1 elements. | ||||
Description | I noticed, that when I create TJclQueue with capacity 1, then I can't enqueue any objects. And debugging it I discovered, that actual problem is in all queue classes and is, that if queue size equal to capacity - 1, then it can't add any more elements because it fails to grow. | ||||
Additional Information | Following sample program demonstrates the problem (program output will be: Enqueueing HELLO failed Enqueueing WORLD failed ). (********************************************) program queue; {$APPTYPE CONSOLE} uses JclContainerIntf, JclQueues; var SQ: IJclStrQueue; begin SQ := TJclStrQueue.Create(1); if not SQ.Enqueue('HELLO') then writeln('Enqueueing HELLO failed') else writeln('Enqueueing HELLO succeeded'); if not SQ.Enqueue('WORLD') then writeln('Enqueueing WORLD failed') else writeln('Enqueueing WORLD succeeded'); end. (********************************************) Simplest solution would be to override AutoGrow for all Queue classes as: //+ 1 is needed, because queue must be 1 larger if FHead > FTail then SetCapacity(CalcGrowCapacity(FCapacity, FCapacity - FHead + FTail + 1)) // looped else SetCapacity(CalcGrowCapacity(FCapacity, FTail - FHead + 1)); Actually, all AbstractContainer methods using FSize will need overriding because Queue classes do not use FSize and it is always 0. That is separate issue. | ||||
Tags | No tags attached. | ||||
Fixed in GIT commit | |||||
Fixed in SVN revision | |||||
IDE version | All | ||||
Date Modified | Username | Field | Change |
---|---|---|---|
2018-06-05 09:57 | virgoparna | New Issue | |
2018-06-05 09:57 | virgoparna | IDE version | => All |