Leaderboard
Popular Content
Showing content with the highest reputation on 01/25/23 in all areas
-
What are the correct settings for "Code inlining control"?
Stefan Glienke replied to Der schöne Günther's topic in RTL and Delphi Object Pascal
I would never ever turn it to AUTO because that causes the compiler to inline every function that has a size of 32 bytes or less. The inliner of the Delphi compiler is really bad and while one might think that inlining code usually makes stuff better/faster that is not the case and usually (decent) library developers know where to put inline and where not to put inline. -
Generic from the RTL for sorted list of objects
Stefan Glienke replied to dummzeuch's topic in RTL and Delphi Object Pascal
No, because the parameterless TObjectList<T> constructor sets OwnsObjects to True. And that is nothing new but also already was the case in the old TObjectList from Contnrs.pas I am glad I can use Spring4D and have several flavors of multimaps at my disposal -
Generic from the RTL for sorted list of objects
Uwe Raabe replied to dummzeuch's topic in RTL and Delphi Object Pascal
type TObjectDictionaryWithDuplicateObjects<K,V:class> = class(TObjectDictionary<K, TObjectList<V>>) public procedure AddObject(const Key: K; Value: V); end; procedure TObjectDictionaryWithDuplicateObjects<K, V>.AddObject(const Key: K; Value: V); var list: TObjectList<V>; begin if not TryGetValue(Key, list) then begin list := TObjectList<V>.Create; Add(Key, list); end; list.Add(Value); end; -
Generic from the RTL for sorted list of objects
aehimself replied to dummzeuch's topic in RTL and Delphi Object Pascal
Only if you create them like: TObjectDictionary<T>.Create([doOwnsValues]); TObjectList<T>.Create(True); -
Generic from the RTL for sorted list of objects
programmerdelphi2k replied to dummzeuch's topic in RTL and Delphi Object Pascal
my test for TObject or any other type, you can create yourself class for easy access using another types -- not copyed, not chatBOTs >:))) implementation {$R *.dfm} uses System.Generics.Collections; type TMyObjList = TObjectList<TObject>; TMyDicObjList = TDictionary<string, TMyObjList>; var LDic: TMyDicObjList; procedure MyShowingObjects(const ADic: TMyDicObjList; const LClearMemo: boolean = false); var LText: string; begin for var K in ADic do begin LText := LText + '...Key = ' + K.Key + ', Addr = ' + integer(K.Value).ToString + slinebreak; // for var V in TMyObjList(K.Value) do LText := LText + '......Value = ' + V.ToString + ', Addr = ' + integer(V).ToString + slinebreak; end; // if LClearMemo then Form1.Memo1.Text := LText else Form1.Memo1.Lines.Add(LText); end; procedure MyFreeObjectsFromList(const ADic: TMyDicObjList); //var // LO: TMyObjList; begin while (LDic.Count > 0) do begin for var K in LDic.Keys do begin //if LDic.TryGetValue(K, LO) then // I forgot that I use "True" param in "LDic.Add(LKey, TMyObjList.Create(true));"!!! // begin // for var V in LO do // LDic[K].Remove(V); // remove TObject // FreeAndNil(LDic[K]); // remove TObjectList // end; // LDic.Remove(K); // remove Keys end; end; end; function MyFindObject(const ADic: TMyDicObjList; const AKey: string = ''; const AObjAddress: integer = 0): TObject; begin result := nil; // if (ADic = nil) or (ADic.Count = 0) or (AObjAddress < 1) then exit; // if (AKey = '') then begin for var K in ADic.Keys do for var O in ADic[K] do if integer(O) = AObjAddress then exit(O); end else begin if ADic.ContainsKey(AKey) then for var O in ADic[AKey] do if integer(O) = AObjAddress then exit(O); end; end; procedure TForm1.FormCreate(Sender: TObject); begin LDic := TMyDicObjList.Create; end; procedure TForm1.FormDestroy(Sender: TObject); begin MyFreeObjectsFromList(LDic); // LDic.Free; end; procedure TForm1.BtnAddObjectListHelloClick(Sender: TObject); var LKey: string; begin LKey := BtnAddObjectListHello.Caption; // if not LDic.ContainsKey(LKey) then LDic.Add(LKey, TMyObjList.Create(true)); // LDic[LKey].Add(TObject.Create); // MyShowingObjects(LDic, true); end; procedure TForm1.BtnAddObjectListWolrdClick(Sender: TObject); var LKey: string; begin LKey := BtnAddObjectListWolrd.Caption; // if not LDic.ContainsKey(LKey) then LDic.Add(LKey, TMyObjList.Create(true)); // LDic[LKey].Add(TObject.Create); // MyShowingObjects(LDic, true); end; procedure TForm1.BtnGetObjectOnListClick(Sender: TObject); var O: TObject; begin O := MyFindObject(LDic, Trim(EdtKey.Text), StrToIntDef(EdtAddress.Text, -1)); // by address or any other from class! // if (O <> nil) then Memo1.Lines.Add('Obj found = ' + integer(O).ToString) else Memo1.Lines.Add('Obj = Not Found'); end; procedure TForm1.BtnDeleteAllObjectsClick(Sender: TObject); begin MyFreeObjectsFromList(LDic); // MyShowingObjects(LDic, true); end; initialization ReportMemoryLeaksOnShutdown := true; end. -
Generic from the RTL for sorted list of objects
dummzeuch replied to dummzeuch's topic in RTL and Delphi Object Pascal
You're still miffed, apparently. -
Generic from the RTL for sorted list of objects
Tom Chamberlain replied to dummzeuch's topic in RTL and Delphi Object Pascal
It works better if you can break it down and use a key for the child objects also: TChildList = TObjectDictionary<UniqueKey, TMyClass>; MyList: TObjectDictionary<String, TChildList>; UniqueKey is a priority/sequence number in our system for each unique child, we use an integer. This makes searching and processing child objects simple. var localChild: TMyclass; if MyList.ContainsKey(SearchString) then for localChild in Mylist[SearchString].Values do begin localChild.....whatever end; and if MyList.ContainsKey(SearchString) then if MyList[SearchString].ContainsKey(UniqueKey) then begin localChild := MyList[SearchString].Items[UniqueKey]; localChild...whatever end; -
Actually one need to enter just MYDEF, just like you do for the Defines in the compiler options or the options of the Unit Dependency Analyzer. BUT, there is a refresh problem in the current MMX version: You have to restart the IDE to make the MMX parser reload the defines. Of course that is quite buggy, as even switching the project misses to update the defines for the parser. I will fix that with the next version.
-
Generic from the RTL for sorted list of objects
aehimself replied to dummzeuch's topic in RTL and Delphi Object Pascal
You always can use a TObjectDictionary<String, TObjectList<TMyClass>>. That way you can have multiple instances of TMyClass assigned to the same string key. -
Generic from the RTL for sorted list of objects
David Heffernan replied to dummzeuch's topic in RTL and Delphi Object Pascal
I don't think there is any generic collection that meets your needs in the rtl. Perhaps you'll just have to give up. -
"Divided by zero" exception
David Heffernan replied to Mohammad Atikur Rhaman's topic in General Help
Why let lack of knowledge get in the way of offering suggestions? -
Hi, thanks. Oh no worries, I welcome all feedback. I just committed a huge update to the repo today with all of that and more. There is a new unit GamePascal.Framework, there is a new class TGame that you can derive your games from with all of what you suggested built in. TGame, TActor, TActorList, TActorScene together allow you to have a dynamic and responsive OOP system to manage your game. All the examples have been updated to take advantage of this.
- 8 replies
-
- object pascal
- gamedev
-
(and 6 more)
Tagged with:
-
@WhitePortal Either your firewall, your router, DNS / hosts file, or your internet service provider, or something on the Embarcadero side of things is not letting your traffic through.
-
Delphi 11.2 unofficial LSP patch
pyscripter replied to Brandon Staggs's topic in Delphi IDE and APIs
FWIW, I have tried the unofficial LSP patches and I could no longer debug programs. So I went back to the original dlls and debugging was available again.