Recent

Author Topic: TCollection.Move not implemented?  (Read 3516 times)

Alextp

  • Hero Member
  • *****
  • Posts: 889
    • UVviewsoft
TCollection.Move not implemented?
« on: November 09, 2017, 10:36:36 am »
I can't see TCollection.Move() in fpc 3.0.2, so i must do workaround to change item index: Items[nFrom].Index:= nTo.
Pls publish Move() method.
It exists in TList.
« Last Edit: November 11, 2017, 07:30:30 pm by Alextp »

Thaddy

  • Hero Member
  • *****
  • Posts: 9190
Re: TCollection.Move not implemented?
« Reply #1 on: November 09, 2017, 11:45:18 am »
Which Tlist? Classes? FGL? Generics.collections?
also related to equus asinus.

Alextp

  • Hero Member
  • *****
  • Posts: 889
    • UVviewsoft
Re: TCollection.Move not implemented?
« Reply #2 on: November 09, 2017, 12:54:07 pm »
Classes.TList has Move method.

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1249
Re: TCollection.Move not implemented?
« Reply #3 on: November 11, 2017, 07:07:10 pm »
Which Tlist? Classes? FGL? Generics.collections?

I was also confused, then I saw the subject name :-)
"TCollection.Move not implemented?"
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

Alextp

  • Hero Member
  • *****
  • Posts: 889
    • UVviewsoft
Re: TCollection.Move not implemented?
« Reply #4 on: November 11, 2017, 07:31:00 pm »
Yes, pls implement Move() in TCollection.

wp

  • Hero Member
  • *****
  • Posts: 6356
Re: TCollection.Move not implemented?
« Reply #5 on: November 11, 2017, 07:46:06 pm »
What is the problem in calling Collection.Item[ i].Index := new_index? Delphi's TCollection doesn't have it either.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1249
Re: TCollection.Move not implemented?
« Reply #6 on: November 11, 2017, 07:54:42 pm »
I see, TCollectionItem.SetIndex call's FPList move().

The only problem I can see is that this is a un-intuitive.  The other lists in the unit have a Move(), so I understand Alextp's issue finding this solution.

I'd recommend slipping this request onto FPC Mantis, preferably with a patch.  The code for Move() should be simply, just set the index.
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

BrunoK

  • Full Member
  • ***
  • Posts: 190
  • Retired programmer
Re: TCollection.Move not implemented?
« Reply #7 on: April 10, 2019, 02:02:01 pm »
laz.virtualtrees.pas(8243,122) Error: Wrong number of parameters specified for call to "Move"

FPC issue 0032673, patch 41795 (added move) breaks laz.virtualtrees \components\virtualtreeview\laz.virtualtrees.pas at line
8243 (and others)
Code: Pascal  [Select]
  1. 8243       Move(FPositionToIndex[OldPosition + 1], FPositionToIndex[OldPosition], (Position - OldPosition) * SizeOf(Cardinal));
  2.  
Lazarus trunk r. 62137/27.10.2019 (+/- patches regarding TScrollBar, IntitalSetupDialog, Options.Environment options, SearchResults).  Lazarus 3.0.6 raw from svn.
FPC 3.0.4 32 bits. (+heaptrc with leaked ClassName+Revisited TList) , Windows 10 Pro x64 (v. 1903 / 18362.418)