While I haven't looked into the backend of what separates irr::array from vector, I have come to find that irr::array is a much more durable and powerful implementation of dynamic array creation and usage, especially inside Irrlicht.
I stumbled upon this when I was using a vector for an array of vertexes and indexes, which produced extra data. Simply replacing vector with core::array solved EVERYTHING!
This should be duly noted somewhere, probably not here, but probably in the tutorials for those like me who need to make dynamic models within their own engine, since some things shouldn't rely on external model files.
Use of irr::array: VERY recommended!
I wouldn't say that so general. I always use Irrlicht arrays when I need to access specific entries directly (e.g. the 3rd), but when I just have to iterate I use the list (I guess it's faster - though I haven't tested that). Works fine for me.
Dustbin::Games on the web: https://www.dustbin-online.de/
Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Initially I have simply used array everywhere rather than list.
If I want to iterate over the array, I grab the .pointer() to the data of the array, then iterate over it like a normal C array. I believe this is much faster than iterating using irrArray. At the same time, I can get direct access if I want using irrArray directly.
I believe that the list is only better if you are performing many insertions and deletions, as it does not need to shift the elements.
If I want to iterate over the array, I grab the .pointer() to the data of the array, then iterate over it like a normal C array. I believe this is much faster than iterating using irrArray. At the same time, I can get direct access if I want using irrArray directly.
I believe that the list is only better if you are performing many insertions and deletions, as it does not need to shift the elements.
I can hear birds chirping
I live in the Eye of Insanity.
I live in the Eye of Insanity.
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
The 2nd table is interesting.Ulf wrote:I believe that the list is only better if you are performing many insertions and deletions, as it does not need to shift the elements.
"Whoops..."
I only had a quick think, but isn't the table incorrect?
Excuse me if I misunderstand but for the list, if it takes O(N) to access the middle, must it not take O(N) to insert in the middle? You need to iterate to the middle first to insert a new item.
If it is a sorted list, it will be O(logN).
Whereas if the array is sorted, inserting at the start or middle will always be O(N).
Excuse me if I misunderstand but for the list, if it takes O(N) to access the middle, must it not take O(N) to insert in the middle? You need to iterate to the middle first to insert a new item.
If it is a sorted list, it will be O(logN).
Whereas if the array is sorted, inserting at the start or middle will always be O(N).
I can hear birds chirping
I live in the Eye of Insanity.
I live in the Eye of Insanity.
Technicaly correct but: you are not randomly inserting in the middle most of the time you will already have your handle. For example my Entities are in a array for quick id acces over the network and at the same time in a list. they store both the array id and the list iterator to there location to quickly erase them or insert something behind them.Ulf wrote: Excuse me if I misunderstand but for the list, if it takes O(N) to access the middle, must it not take O(N) to insert in the middle? You need to iterate to the middle first to insert a new item..
Another place where i use it is in my octreescenemanager. evey cell has a list of entries and bc when a object is moving it needs to be quickly removed and added to different cells so it stores the list iterator along the way.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.