Thanks for your help, I will try and find out more on the slow connection. ----- Original Message ----- From: "Angela Tocco" <[EMAIL PROTECTED]> To: <ADVANCED-DOTNET@DISCUSS.DEVELOP.COM> Sent: Sunday, May 01, 2005 3:37 AM Subject: Re: [ADVANCED-DOTNET] Circular Buffer using ArrayList or Hashtable
And to add to this. Earlier in this discussion myself and another poster came to the conclusion that the hashtable isn't being locked per say, its probably the internet connection that is slow. That being said, the only usefulness of the circular buffer that I can figure right now, is to cache the images that would of previously been missed because of reading/writing at the same time.
Hope this makes sense.
Have a great weekend.
Steve
-----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Angela Tocco Sent: Saturday, April 30, 2005 9:20 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Circular Buffer using ArrayList or Hashtable
Thank you for your reply. The main reason for the circular buffer is to store images in this Hashtable that two processes are looking at. One writes to it and the other reads from it. This scenario seemed perfect for the circular buffer because it allows it to be read and wrote too async. And without locks. The issue I seem to have is my hashtable is being read and written too at the same time and seems to either lock out one of the processes or the data its trying to read is being replaced with new information. I am reading and writing every second.
One of the code examples I looked at was the circular buffer found at the CodeProject. Seemed easy to use and was fast. Only problem was I couldn't incorporate my current Hashtable to use the .dll that was included because it used its own.
Just a quick note, the hashtable itself keeps the machine names of currently logged in users. An application on the users machine populates this hashtable with information. The keys to the hashtable are the machinenames so that I can query the hashtable and say 'give me the information for computer 123' and the hashtable searchs the keys for a match on computer name and gives me the info in it.
Explaining that I just realized why I couldn't use a hashtable...to make a hashtable circular there would have to be duplicate keys. Why I don't think of these before I write messages I have no clue.
Thanks for your time on this. If you have any suggestions on how to implement this for use of caching bitmaps I would love to hear it.
Have a great weekend.
Steve
-----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Frans Bouma Sent: Saturday, April 30, 2005 4:16 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Circular Buffer using ArrayList or Hashtable
Is it possible to create a circular buffer using an ArrayList or Hashtable? I've seen several examples that seem to work, but they are using an array. I was going to use this method to cache bitmaps and hold about 5 at a time. Seems like a cool idea I just don't want to have to rewrite everything I have now to use a standard array. Im happy with my Hashtable since my Hashtable keys are computernames that are currently logged in.
A circular buffer is mostly used to store 'the last n' elements, i.e. having a fixed sized buffer but without the border checks. Often it's not used to index into these buffers, just read from the head and store in the buffer, like a soundbuffer in a music player. In a way it's similar to a queue. (so you can use a Queue object as well, though you lose the fixed size element)
It's not hard to write one using an Array, as you just have to keep track of what's the current free slot. You can also use an arraylist for this but that's overkill, as the principle of creating the circular buffer is the same. I don't see how a hashtable could help.
Circular lists (i.e. objects linked with a previous and a next) are more efficient to maintain. Circular buffers don't have a lot of use.
FB
=================================== This list is hosted by DevelopMentor. http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
=================================== This list is hosted by DevelopMentor. http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
=================================== This list is hosted by DevelopMentorŪ http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
=================================== This list is hosted by DevelopMentorŪ http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com