avk959 / lgenerics Goto Github PK
View Code? Open in Web Editor NEWGeneric algorithms and data structures for Lazarus/Free Pascal
License: Apache License 2.0
Generic algorithms and data structures for Lazarus/Free Pascal
License: Apache License 2.0
what do you think, about JSON code is needing to be separate package? it is so general for using. ie I want to use JSON code only and not the rest of the stuff.
const
DEFAULT_DEPTH = TJsonReader.DEF_DEPTH;
DEFAULT_BUF_SIZE = TJsonReader.DEF_BUF_SIZE;
Error is
lgasync.pas(2103,13) Error: Incompatible types: got "ShortInt" expected "TThreadID"
fpc 3.2.2 Lazarus 2.2.6
MacOS Ventura 13.6.1
Fixed locally by changing
lgAsync line 2103 from Result :=0; to Result := TThreadId(0);
and
lgAsync line 2110 from Result := 0; to Result := TThreadId(0);
I cannot yet try your json code in CudaText because I have too many code for TJsonConfig, hard to edit it all. But if you give some 'compat layer' for it, I will try it. I can change type "TJsonConfig" in all places to other, but I don't want to edit code.
Hello avk959!
Thank you very much for excellent LGenerics library!
I encountered an issue when applying HashMap. but I cannot determine whether it is due to the compiler or LGenrics.
type
TTestMapSpec=specialize TGLiteHashMapLP<string, string, string>;
TTestMap=TTestMapSpec TMap;
TFoo=class
private
FMap: TTestMap;
procedure DoInitialize; // Here, some Key-Val will be inserted into FMap
procedure DoFinalize;
public
constructor Create; // Calling DoInitialize
destroyer Destroy; override;
end;
----TFoo is working properly. But if a TBar is derived from TFoo, such as:
TBar=class (TFoo)
public
constructor Create; // Call TFoo.Create
destroyer Destroy; override;
end;
----Execute TBar.Create will result in a memory overflow.
Tracking the code reveals that it is constantly calling TGLiteHashTableLP.Resize(aNewCapacity: SizeInt);
The difference is:
The "class operator TGLiteHashTableLP.Initialize(var ht: TGLiteHashTableLP)" is called before the body of the TFoo.Create
while call TFoo.Create DIRECTLY, and it will be NOT while “TBar.Create ->TFoo.Create".
************so, it seems to be related to initialization, so
if defined
TTestMap=specialize TGHashMapLP<string, string>;
Modify
TFoo.DoInitialize;
begin
FMap := TTestMap.Create; // add this line, do Initialization
...
end;
--- both TFoo.Create and TBar.Create are working properly.
Test Enviroment: Win7-x64, Lazarus 3.2/FPC 3.2.2; LGenerics 0.56 or master version
the test code attached here, note that the conditional compilation
fb.zip
{$DEFINE LITE_VERSION} // undefine this, both TFoo and TBar are working properly.
// define LITE_VERSION, TFoo working properly, TBar go wrong.
resourcestring
SEInvalidJsonFile = '"%s" is not a valid JSON configuration file';
SECouldNotOpenKey = 'Could not open key "%s"';
They may conflict with user-defined names
They're both real words, but they have very different meanings:
Equitable means "fair and impartial".
Equatable is the one relevant to hashmaps, and means "capable of being compared".
on MX-Linux, Mint Linux, code like here will raise invalid pointer error, but on Windows 7, everything go right
and if I switch back to LGenerics_054, non error
// my test code
type
TWordSetSpec = specialize TGLiteTreeSet<string, string>;
var
ws: TWordSetSpec;
begin
ws.Add('S1');
ws.Add('M2');
ws.Add('K3');
for s in ws do
Memo1.Append(s); // first 'K3' , Okay; but Next, Raise error at lgAvlTree line 2666
end;
// the lgAvlTree .pas
function TGLiteAvlTree.TEnumerator.MoveNext: Boolean;
var
NextNode: SizeInt = 0;
begin
if FCurrNode <> 0 then
NextNode := FTree^.Successor(FCurrNode) // this line(2666), FTree INVALID pointer error
else
...
Compiler: FPC 3.2.2 Lazarus: 2.2.6
Ca you add such .txt files to repo?
I am interested in JSON only-- but other tests are good as well...
Hi,
i want to use your package lgenerics at first time. But i have a problem to compile the package.
Can you tell me what can i do, whats wrong?
Thanks for your efforts.
On compile lgenerics.lpk, the following error message appears:
Hint: (11030) Start of reading config file C:\lazarus\fpc\3.2.0\bin\i386-win32\fpc.cfg
Hint: (11031) End of reading config file C:\lazarus\fpc\3.2.0\bin\i386-win32\fpc.cfg
Free Pascal Compiler version 3.2.0 [2020/07/07] for i386
Copyright (c) 1993-2020 by Florian Klaempfl and others
(1002) Target OS: Win32 for i386
(3104) Compiling lgenerics.pas
(3104) Compiling lgabstractcontainer.pas
(3104) Compiling lgutils.pas
(3104) Compiling lgstrconst.pas
(1010) Writing Resource String Table file: lgstrconst.rsj
(3104) Compiling lghelpers.pas
(3104) Compiling lghash.pas
..\LGenerics-master\lgenerics\lghelpers.pas(670,36) Hint: (4055) Conversion between ordinals and pointers is not portable
(3104) Compiling lgarrayhelpers.pas
..\LGenerics-master\lgenerics\lgarrayhelpers.pas(14980,23) Hint: (5058) Variable "aOfs" does not seem to be initialized
..\LGenerics-master\lgenerics\lgarrayhelpers.pas(33,8) Hint: (5023) Unit "lgHelpers" not used in lgArrayHelpers
(3104) Compiling lgasync.pas
(3104) Compiling lgqueue.pas
(3104) Compiling lgvector.pas
..\LGenerics-master\lgenerics\lgvector.pas(2541,41) Note: (6058) Call to subroutine "function BsfQWord(const AValue:QWord):DWord;" marked as inline is not inlined
(3104) Compiling lgpriorityqueue.pas
(3104) Compiling lgfunction.pas
(3104) Compiling lghashtable.pas
..\LGenerics-master\lgenerics\lghashtable.pas(34,8) Hint: (5023) Unit "lgHelpers" not used in lgHashTable
..\LGenerics-master\lgenerics\lgfunction.pas(181,3) Error: (1026) Compilation raised exception internally
Fatal: (1018) Compilation aborted
An unhandled exception occurred at $00470C1E:
EAccessViolation: Access violation
$00470C1E
$004AFED0
$004AED50
$004C61F0
$004C6B88
$004366BC
$004B7076
$00569C44
$0056AACE
$004366BC
$004B7076
$00569C44
$0056AACE
$004366BC
$00414D05
Error: C:\lazarus\fpc\3.2.0\bin\i386-win32\ppc386.exe returned an error exitcode
Hello,
I recently upgraded FPC to most recent trunk snapshot and am now facing the following errors in compiling lgint128:
lgint128.pas(1110,16) Error: No size specified and unable to determine the size of the operands
lgint128.pas(1673,15) Error: No size specified and unable to determine the size of the operands
lgint128.pas(1682,15) Error: No size specified and unable to determine the size of the operands
lgint128.pas(1684,15) Error: No size specified and unable to determine the size of the operands
lgint128.pas(1734,15) Error: No size specified and unable to determine the size of the operands
I don't have much experience in ASM, so I appreciate any help to fix this error.
I am trying to cross-compile from win64 to win32.
Thank you :)
TintChart.FindMaxClique failes with message Acces Violation in file lgsimplegraph.pas line 1642
function TGSimpleGraph.FindChordalMaxClique(out aClique: TIntSet): Boolean;
procedure NodeDone(aIndex: SizeInt; const aLefts: TIntSet);
begin
if aLefts.Count > Pred(aClique.Count) then
begin
aClique.Assign(aLefts);
aClique.Push(aIndex);
end;
end;
var
Dummy: TIntArray;
begin
aClique.Clear;
Result := FindPerfectElimOrd(@NodeDone, Dummy);
if not Result then
aClique.Clear;
end;
LGenerics/lgenerics/LGArrayHelpers.pas
Line 1662 in e8738d9
J := Random(I);
should be:
J := Random(I+1);
References:
https://forum.lazarus.freepascal.org/index.php/topic,36445.msg349000.html#msg349000
https://forum.lazarus.freepascal.org/index.php?topic=36445.msg349076#msg349076
https://bugs.freepascal.org/view.php?id=36696
Hi @avk959,
Thanks for the fine library for FPC. I am runnning into issues when compiling with FPC trunk and using lghashmap
.
I get the following error.
Compile Project, Mode: Release, Target: C:\Users\iwank\<secret>\1brc-ObjectPascal\bin\ikelaiah.exe: Exit code 1, Errors: 40, Hints: 2
Hint: Start of reading config file C:\fpcupdeluxe\fpc\bin\x86_64-win64\fpc.cfg
Hint: End of reading config file C:\fpcupdeluxe\fpc\bin\x86_64-win64\fpc.cfg
Verbose: Free Pascal Compiler version 3.3.1-15663-ga888a141a2 [2024/05/04] for x86_64
Verbose: Copyright (c) 1993-2024 by Florian Klaempfl and others
Verbose: Target OS: Win64 for x64
Verbose: Compiling OneBRC.lpr
Verbose: Compiling weatherstation.pas
lgabstractcontainer.pas(140,6) Error: No matching implementation for interface method "FindFirst(out OpenString):System.Boolean;" found
lgabstractcontainer.pas(140,6) Error: No matching implementation for interface method "FindLast(out OpenString):System.Boolean;" found
lgabstractcontainer.pas(140,6) Error: No matching implementation for interface method "FindMin(out OpenString;TGLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgabstractcontainer.pas(140,6) Error: No matching implementation for interface method "FindMin(out OpenString;TGOnLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgabstractcontainer.pas(140,6) Error: No matching implementation for interface method "FindMin(out OpenString;TGNestLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgabstractcontainer.pas(140,6) Error: No matching implementation for interface method "FindMax(out OpenString;TGLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgabstractcontainer.pas(140,6) Error: No matching implementation for interface method "FindMax(out OpenString;TGOnLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgabstractcontainer.pas(140,6) Error: No matching implementation for interface method "FindMax(out OpenString;TGNestLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
enumsh.inc(25,19) Error: No matching implementation for interface method "FindFirst(out OpenString):System.Boolean;" found
enumsh.inc(25,19) Error: No matching implementation for interface method "FindLast(out OpenString):System.Boolean;" found
enumsh.inc(25,19) Error: No matching implementation for interface method "FindMin(out OpenString;TGLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
enumsh.inc(25,19) Error: No matching implementation for interface method "FindMin(out OpenString;TGOnLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
enumsh.inc(25,19) Error: No matching implementation for interface method "FindMin(out OpenString;TGNestLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
enumsh.inc(25,19) Error: No matching implementation for interface method "FindMax(out OpenString;TGLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
enumsh.inc(25,19) Error: No matching implementation for interface method "FindMax(out OpenString;TGOnLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
enumsh.inc(25,19) Error: No matching implementation for interface method "FindMax(out OpenString;TGNestLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgabstractcontainer.pas(201,6) Error: No matching implementation for interface method "FindFirst(out OpenString):System.Boolean;" found
lgabstractcontainer.pas(201,6) Error: No matching implementation for interface method "FindLast(out OpenString):System.Boolean;" found
lgabstractcontainer.pas(201,6) Error: No matching implementation for interface method "FindMin(out OpenString;TGLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgabstractcontainer.pas(201,6) Error: No matching implementation for interface method "FindMin(out OpenString;TGOnLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgabstractcontainer.pas(201,6) Error: No matching implementation for interface method "FindMin(out OpenString;TGNestLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgabstractcontainer.pas(201,6) Error: No matching implementation for interface method "FindMax(out OpenString;TGLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgabstractcontainer.pas(201,6) Error: No matching implementation for interface method "FindMax(out OpenString;TGOnLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgabstractcontainer.pas(201,6) Error: No matching implementation for interface method "FindMax(out OpenString;TGNestLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindFirst(out OpenString):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindLast(out OpenString):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindMin(out OpenString;TGLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindMin(out OpenString;TGOnLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindMin(out OpenString;TGNestLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindMax(out OpenString;TGLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindMax(out OpenString;TGOnLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindMax(out OpenString;TGNestLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindFirst(out OpenString):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindLast(out OpenString):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindMin(out OpenString;TGLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindMin(out OpenString;TGOnLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindMin(out OpenString;TGNestLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindMax(out OpenString;TGLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindMax(out OpenString;TGOnLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
lgutils.pas(259,6) Error: No matching implementation for interface method "FindMax(out OpenString;TGNestLessCompare$1$crc640B6513_crc69E394E1):System.Boolean;" found
weatherstation.pas(66,1) Verbose: There were 40 errors compiling module, stopping
Verbose: Compilation aborted
Verbose: C:\fpcupdeluxe\fpc\bin\x86_64-win64\ppcx64.exe returned an error exitcode
Can you help?
Many thanks.
-Iwan
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.