|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
simple queuerecent status messages. i don't want to do a whole bunch of parsing of text; and string concat. Dim s As New Stack() s.Push("This") s.Push("Is") s.Push("How") s.Push("Stacks") s.Push("Work") Console.WriteLine(s.Peek()) i saw this example; this is awfully similiar to what i want to do-- would it be crazy to make 20 different stacks stack20->stack19->stack18-> i just dont get it; and i would LOVE a little bit of guidance. i want to be able to push Aaron Matt Ray and then add a new member 'Jose' which would give me Jose Aaron Matt thanks team!! aaron.ke***@gmail.com wrote:
Show quoteHide quote > i need a status box on my etl tool-- where i can 'trap' the 20 most There is a Queue collection type that may do what you want.> recent status messages. > > i don't want to do a whole bunch of parsing of text; and string concat. > > Dim s As New Stack() > > s.Push("This") > s.Push("Is") > s.Push("How") > s.Push("Stacks") > s.Push("Work") > Console.WriteLine(s.Peek()) > > > > i saw this example; this is awfully similiar to what i want to do-- > would it be crazy to make 20 different stacks > > stack20->stack19->stack18-> > > i just dont get it; and i would LOVE a little bit of guidance. > > i want to be able to push > > Aaron > Matt > Ray > > and then add a new member 'Jose' > > which would give me > > Jose > Aaron > Matt > > thanks team!! > Chris It all depends on how you want to interrogate the 'queue'.
A Stack object is LIFO (Last In - First Out) and controlling the number of entries in the stack is not a trivial exercise. Also when you 'pop' a value from the stack, the value is removed from the stack. Example: Dim _s As New Stack() _s.Push("Status Message 1") _s.Push("Status Message 2") ... _s.Push("Status Message 10") Console.WriteLine(_s.Pop()) Console.WriteLine(_s.Pop()) ... Console.WriteLine(_s.Pop()) Gives: Status Message 10 ... Status Message 2 Status Message 1 and the stack is now empty. A Queue object is FIFO (First In - First Out) and controlling the number of entries in the queue is musch easier. Also when you 'dequeue' a value from the queue, the value is removed from the stack. Dim _q As New Queue() _q.Enqueue("Status Message 1") _q.Enqueue("Status Message 2") ... _q.Enqueue("Status Message 10") Console.WriteLine(_q.Dequeue()) Console.WriteLine(_q.Dequeue()) ... Console.WriteLine(_q.Dequeue()) Gives: Status Message 1 Status Message 2 ... Status Message 10 and the queue is now empty. To control the number of entries: If _q.Count = 20 then 'Dequeue the oldest entry and dump it _q.Dequeue() End If _q.Enqueue("Next Status Message") If you want to repeatedly the most recent 20 (or up to the most recent 20 rentries), I would be inclined to simply use an ArrayList object and control the count. Dim _a As New Queue() _a.Add("Status Message 1") _a.Add("Status Message 2") ... _a.Add("Status Message 10") For _i = 0 to _a.Count - 1 Console.WriteLine(_a(_i)) Next Gives: Status Message 1 Status Message 2 ... Status Message 10 and the entries are still in the arraylist. To control the number of entries: If _a.Count = 20 then 'Remove the oldest entry _a.RemoveAt(0) End If _a.Add("Next Status Message") If you want to read the arraylist from most recent to oldset, simply reverse the order of the loop: For _i = _a.Count - 1 to 0 Step -1 Console.WriteLine(_a(_i)) Next <aaron.ke***@gmail.com> wrote in message Show quoteHide quote news:1144717626.281047.51050@j33g2000cwa.googlegroups.com... >i need a status box on my etl tool-- where i can 'trap' the 20 most > recent status messages. > > i don't want to do a whole bunch of parsing of text; and string concat. > > Dim s As New Stack() > > s.Push("This") > s.Push("Is") > s.Push("How") > s.Push("Stacks") > s.Push("Work") > Console.WriteLine(s.Peek()) > > > > i saw this example; this is awfully similiar to what i want to do-- > would it be crazy to make 20 different stacks > > stack20->stack19->stack18-> > > i just dont get it; and i would LOVE a little bit of guidance. > > i want to be able to push > > Aaron > Matt > Ray > > and then add a new member 'Jose' > > which would give me > > Jose > Aaron > Matt > > thanks team!! > Aaron,
You mean something as an Listbox or whatever in what you deleteAt index 1 forever the first row as the total amount of rows is greather than 19 and remove at (0) and add the latest everytime at the end http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistboxobjectcollectionclassremoveattopic.asp There are more controls with which you can do this. If it has to be a kind of array, than I would use the ArrayList. In my opinion is the (by me very much liked) queue class not the right one for this because it is more to take and put objects automaticly in the queue and not to show the items of that queue. I hope this helps, Cor <aaron.ke***@gmail.com> schreef in bericht Show quoteHide quote news:1144717626.281047.51050@j33g2000cwa.googlegroups.com... >i need a status box on my etl tool-- where i can 'trap' the 20 most > recent status messages. > > i don't want to do a whole bunch of parsing of text; and string concat. > > Dim s As New Stack() > > s.Push("This") > s.Push("Is") > s.Push("How") > s.Push("Stacks") > s.Push("Work") > Console.WriteLine(s.Peek()) > > > > i saw this example; this is awfully similiar to what i want to do-- > would it be crazy to make 20 different stacks > > stack20->stack19->stack18-> > > i just dont get it; and i would LOVE a little bit of guidance. > > i want to be able to push > > Aaron > Matt > Ray > > and then add a new member 'Jose' > > which would give me > > Jose > Aaron > Matt > > thanks team!! > hey
thanks so much guys; i'm kinda new to the whole .NET world; i just CANT BELIEVE HOW FAST THIS STUFF RUNS!!! (i'm an olap dba who also dabbles in all this newfangled programming stuff) that listbox method might be EXACTLY what i was looking for; i'm going to toy around with that. it just seems a LOT easier (and i assume faster) that all this EnQ and DeQ and iterating through stuff. Thanks a lot; i am really going to dive into this tonight on the bus my current, functional version. It works pretty well; i can just tell it's running a little bit slower than i want. Should i just change the AppendText method to a stringbuilder?? Or is a listbox.objectcollection.removeAt going to be faster and simpler?? Dim Q As New Queue(Of String) Public Sub WriteStatus(ByVal strStatus As String) Dim strWaste As String Dim I As Int16 Q.Enqueue(strStatus) If Q.Count > 15 Then strWaste = Q.Dequeue() End If Me.txtStatus.Clear() I = 0 For Each strMessage As String In Q Select Case I Case 0 txtStatus.AppendText(strMessage) Case Else txtStatus.AppendText(vbCrLf & strMessage) End Select I = +1 Next End Sub
Sub Main() refusing to work
Reading .csv files containing the "-" character Inherent form controls resize Center in Child Inability to trap form.show event Tree view node selection error Filling resized panel with form .net framework No accessible overloaded 'DataRowCollection.Add' can be called without a narrowing conversion. file upload download on aspx problem |
|||||||||||||||||||||||