lists,vectors,dictionaries
-
- Posts: 27
- Joined: Mar 13, 2021 10:18
lists,vectors,dictionaries
Hello. I would like to know if in freebasic there are lists, vectors and dictionaries. I was looking at it in the documentation but I didn't see anything.
Re: lists,vectors,dictionaries
FB's built-in data types include dynamic arrays, strings, and numeric types. The data structures you mention are not part of the FB compiler, nor are implementations provided in the runtime library.
However, If you search this forum, you can find object-oriented implementations of other data structures like lists and hashtables (which are dictionaries). Object-oriented programming allows you to create customized data structures that can act almost like built-in types, with normal expression operators overridden to allow the same syntax as built-in types. Assignment, equality, comparisons, etc. Although FB does not support template-based generic programming like other languages, you can still pretty much make any data structure in FB.
However, If you search this forum, you can find object-oriented implementations of other data structures like lists and hashtables (which are dictionaries). Object-oriented programming allows you to create customized data structures that can act almost like built-in types, with normal expression operators overridden to allow the same syntax as built-in types. Assignment, equality, comparisons, etc. Although FB does not support template-based generic programming like other languages, you can still pretty much make any data structure in FB.
-
- Posts: 27
- Joined: Mar 13, 2021 10:18
Re: lists,vectors,dictionaries
And how can I create a list that allows me to save and delete objects? Some examples to learn.caseih wrote:FB's built-in data types include dynamic arrays, strings, and numeric types. The data structures you mention are not part of the FB compiler, nor are implementations provided in the runtime library.
However, If you search this forum, you can find object-oriented implementations of other data structures like lists and hashtables (which are dictionaries). Object-oriented programming allows you to create customized data structures that can act almost like built-in types, with normal expression operators overridden to allow the same syntax as built-in types. Assignment, equality, comparisons, etc. Although FB does not support template-based generic programming like other languages, you can still pretty much make any data structure in FB.
Re: lists,vectors,dictionaries
For example in the documentation:
Linked Lists
Linked Lists
-
- Posts: 27
- Joined: Mar 13, 2021 10:18
Re: lists,vectors,dictionaries
Thanks for the example.But how is it used? and how to go through that list with a loop?
Re: lists,vectors,dictionaries
A small use case (for integers) is integrated in the code after the declarations (see from line #18 to line #35):
Code: Select all
Dim As listnode Ptr list, node
Dim As Integer Ptr item
list = ListCreate()
item = ListAdd(list, CAllocate(Len(Integer)))
*item = 4
item = ListAdd(list, CAllocate(Len(Integer)))
*item = 44
item = 0 ' just to show it works
node = ListGetFirst(list)
While node <> 0
Print "found item"
item = ListGetData(node)
Print *item
node = ListRemove(node,1)
Wend
While Inkey$ = "" : Wend
Re: lists,vectors,dictionaries
FreeBasic containers (map , vector , list , queue , stack)
viewtopic.php?f=8&t=29320
viewtopic.php?f=8&t=29320
-
- Posts: 27
- Joined: Mar 13, 2021 10:18
Re: lists,vectors,dictionaries
Thank you all for the help.
-
- Posts: 538
- Joined: Dec 02, 2011 22:51
- Location: France
Re: lists,vectors,dictionaries
Also have a look to lzle in projects.
-
- Posts: 27
- Joined: Mar 13, 2021 10:18
Re: lists,vectors,dictionaries
Lost Zergling thanks for the suggestion.