jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2010
12:02 AM
Setting a unique value in an RoArray
Does anyone have a good algorithm for adding an element to an roArray and making sure it is unique? I have history as an roarray and want to make sure that any new search entered using an existing search term does not get added to the list. I also want to limit the size of the array to the maximum number of elements in the history list in the search box.
- Joel
- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
3 REPLIES 3
retrotom
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2010
05:50 AM
Re: Setting a unique value in an RoArray
Is there any reason you can't use roAssociativeArray? It uses a key/value pairs and is likely more suited to this. With roArray, you'd have to compare each value in the array. Hopefully roAssociativeArray is O(1) when doing a lookup.
jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2010
10:44 AM
Re: Setting a unique value in an RoArray
The history parameter of a search screen takes an roarray as it's parameter
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
retrotom
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2010
10:54 AM
Re: Setting a unique value in an RoArray
Yeah, so why not take each item in the history roArray and enter it into a roAssociativeArray? Do a lookup before adding a new value to the search history. If you load the roAssociativeArray at application startup, then you can scan then history array once -- and before adding something to the history, you can just do a quick lookup in the roAA. As you add things to history, you can also add to the associative array. Assuming the roAA DoesExist function is O(1), this is more efficient from a performance standpoint and definitely from a coding standpoint. If case sensitivity ever becomes a concern (unlikely), then you have that built in too.