Sign in to follow this  

toroidal array

This topic is 2050 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 everybody,

Can someone write me a few words about what is a toroidal array data type and how it compares with a normal array. The way that I understand it is that it is almost like a circular double linked list with constant size.
If you provide me a link even better.

I did a search over the internet and some books about data structures but I didn't find any relevant and explanatory link.

Thanks

Share this post


Link to post
Share on other sites
For a 2D array with dimensions NxM:

[code]torodial[i, j] = regular[i % N, j % M];[/code]

It doesn't have a use as such, but some algorithms may benefit from this property. For example:[code]A B
C D

// toroidal array now contains sequence:
ABABABABAB
and
ACACACACACACACACACAC....[/code]

It basically just says that rows and columns wrap around.

Share this post


Link to post
Share on other sites
I don't think this would normally be a double-linked list if it's of constant size. You can achieve the same effect by using modulo (%) on the index accessors of a normal 2D array, bounding them within the width or height of the array.

Share this post


Link to post
Share on other sites
[quote name='Antheus' timestamp='1336410002' post='4938110']
It doesn't have a use as such, but some algorithms may benefit from this property.[/quote]
It is however very useful for representing game maps that wrap around at the edges - for instance, when implementing Conway's Game of Life.

Also worth mentioning that GPU texture lookups wrap by default, which provides a very simple case of toroidal access.

Share this post


Link to post
Share on other sites

This topic is 2050 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this