Jump to content
  • Advertisement
Sign in to follow this  
jujumbura

What do I call this structure?

This topic is 2416 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all,

There's a simple construct I often find myself using when programming ( after hearing about how to use it from somebody else ), but I have never known what to call it. It's basically a fixed-size array, with a "count" value that specifies how many items are in it. Whenever you add an item, it always goes on the end. Whenever you remove an item, you pull the item on the end off, and insert it into the hole created by the removed item ( unless the removed item was the end item ).

So it's pretty much just an orderless array, but it's super-useful for accumulation and "choose-one-but-guaranteed-no-repeats" randomness. Plus there's no allocation or copying required, so its very low overhead.

Is there a proper term for this thing? I have been calling it a "Bucket", but that hardly seems informative. I'd greatly appreciate any help with the terminology, and perhaps a more formal definition.

Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Unordered array is about as technical as the naming gets. However, if I'm understanding the statement "choose-one-but-guaranteed-no-repeats" correctly, you've restricted it to an unordered set. Whether your specific optimization technique has a name, I don't know, but you pretty much already know the name of the data structure you've described.

Share this post


Link to post
Share on other sites
I'd call it a "bag", as I don't see how the implementation you've described guarantees no repeats. If you do guarantee no repeats, I would call it an unordered set. However, I'd probably also throw in the modifier "fixed" or "limited", as the container has a defined maximum size.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!