MMPTLIST.INT 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. {========================================================================}
  2. {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
  3. {========================================================================}
  4. {= All Rights Reserved =}
  5. {========================================================================}
  6. {= D 01099 Dresden = Tel.: +0351-8012255 =}
  7. {= Loewenstr.7a = info@swiftsoft.de =}
  8. {========================================================================}
  9. {= Actual versions on http://www.swiftsoft.de/mmtools.html =}
  10. {========================================================================}
  11. {= This code is for reference purposes only and may not be copied or =}
  12. {= distributed in any format electronic or otherwise except one copy =}
  13. {= for backup purposes. =}
  14. {= =}
  15. {= No Delphi Component Kit or Component individually or in a collection=}
  16. {= subclassed or otherwise from the code in this unit, or associated =}
  17. {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
  18. {= without express permission from SwiftSoft. =}
  19. {= =}
  20. {= For more licence informations please refer to the associated =}
  21. {= HelpFile. =}
  22. {========================================================================}
  23. {= $Date: 20.01.1998 - 18:00:00 $ =}
  24. {========================================================================}
  25. unit MMPtList;
  26. {$I COMPILER.INC}
  27. interface
  28. uses
  29. {$IFDEF WIN32}
  30. Windows,
  31. {$ELSE}
  32. WinProcs,
  33. WinTypes,
  34. {$ENDIF}
  35. SysUtils,
  36. Classes,
  37. MMObj,
  38. MMMuldiv,
  39. MMUtils;
  40. type
  41. PMMPoint = ^TMMPoint;
  42. TMMPoint = record
  43. X: Longint;
  44. Y: Longint;
  45. end;
  46. const
  47. { Maximum List size }
  48. MaxListSize = Maxint div (sizeOf(TMMPoint)*sizeOf(TMMPoint));
  49. type
  50. PMMPointArray = ^TMMPointArray;
  51. TMMPointArray = array[0..MaxListSize-1] of TMMPoint;
  52. TMMPointList = class(TMMObject)
  53. public
  54. constructor Create; virtual;
  55. destructor Destroy; override;
  56. procedure Clear; virtual;
  57. procedure Assign(Source: TPersistent);
  58. function Add(Point: TMMPoint): Integer;
  59. procedure Insert(Index: Integer; Point: TMMPoint);
  60. procedure Exchange(Index1, Index2: Integer);
  61. procedure Move(CurIndex, NewIndex: Integer);
  62. function Remove(Point: PMMPoint): Integer;
  63. procedure Delete(Index: Integer);
  64. function IndexOf(Point: PMMPoint): Integer;
  65. function LocatePointX(X: Longint): integer;
  66. function LocatePointY(Y: Longint): integer;
  67. function CalcX(Y: Longint): Longint;
  68. function CalcY(X: Longint): Longint;
  69. procedure SortByX;
  70. procedure SortByY;
  71. function First: PMMPoint;
  72. function Last: PMMPoint;
  73. function Expand: TMMPointList;
  74. property Capacity: Integer read FCapacity write SetCapacity;
  75. property Count: Integer read FCount write SetCount;
  76. property Points[Index: Integer]: PMMPoint read Get write Put; default;
  77. property List: PMMPointArray read FList;
  78. end;
  79. function ComparePoints(Point1,Point2: PMMPoint): Boolean;
  80. function LocateX(Points: PMMPointArray; NumPoints: integer; X: Longint): integer;
  81. function LocateY(Points: PMMPointArray; NumPoints: integer; Y: Longint): integer;
  82. procedure SortX(Points: PMMPointArray; NumPoints: integer);
  83. procedure SortY(Points: PMMPointArray; NumPoints: integer);
  84. implementation