DGL
https://delphigl.com/forum/

Lists
https://delphigl.com/forum/viewtopic.php?f=19&t=8402
Seite 1 von 1

Autor:  Stucuk [ Fr Mai 15, 2009 18:06 ]
Betreff des Beitrags:  Lists

Im wondering what people think is best for storing a list of textures that are currently loaded.

1. Using a TList
2. Using an Array
3. Using a record for each texture which contain a pointer to the next texture.
4. Something Else

Autor:  Lossy eX [ Fr Mai 15, 2009 20:05 ]
Betreff des Beitrags: 

I think this depends on the texturecount and usage. Alternative i can bet hashes. (sorry only german)

Autor:  Stucuk [ Fr Mai 15, 2009 23:02 ]
Betreff des Beitrags: 

Im working on a map editor (Well remaking one which i never finished), so it will have more usage than a game which just loads X amount of textures once per level but at the same time for most of its "Life" it won't be doing much at all. It will only rearly be used to keep a global list of textures (So they can be free'd when the texture system is destroyed if they weren't already destroyed) and to keep the current count of how meny times a texture has been used(So that the system knows when its safe to free the texture). What is the benefit of hashes? Looks simmiler to number 3 on my list except that it also seems to have an array....

Autor:  Deathball [ Fr Mai 15, 2009 23:23 ]
Betreff des Beitrags: 

Stucuk hat geschrieben:
Im working on a map editor (Well remaking one which i never finished), so it will have more usage than a game which just loads X amount of textures once per level but at the same time for most of its "Life" it won't be doing much at all. It will only rearly be used to keep a global list of textures (So they can be free'd when the texture system is destroyed if they weren't already destroyed) and to keep the current count of how meny times a texture has been used(So that the system knows when its safe to free the texture). What is the benefit of hashes? Looks simmiler to number 3 on my list except that it also seems to have an array....


@hashes:
You have an array and an hash function. Every object has an key (i normally use texture name or something like that). The hash function takes the key and returns the index, where the object is located in the array.
So, the advantage is that you can find an entry very fast. You can also find out if an object is already in the data structure or not. You're also able to iterate over the whole set of entries.

It's my favourite data structure for texture managers and stuff like that, but i'm not sure if that structure is what you're looking for.

Autor:  Lord Horazont [ Sa Mai 16, 2009 12:31 ]
Betreff des Beitrags: 

I think, an array (or better, TList) is normaly a fine structure for textures. You load the textures only once and you delete them all at one time, so you do not need the performance bonus you get for deletion and addition when you use linked lists. Accessing could be done either by direct pointers or by indicies. For the first access you could use a "find by name" function, which returns a pointer to the texture object which may be stored for later usage.

greetings Lord Horazont

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/