PC Review


Reply
Thread Tools Rate Thread

Array/collection

 
 
joe
Guest
Posts: n/a
 
      21st Nov 2004
I am trying to track counts of values - I guess an 2-dimn array would be the
way to go?

Basically I want a string in the first position and an integer in the
second:

"This strValue", 5
"That strValue", 21
"Other strValue", 2
....

and i don't know what the values are, nor how many values there will be, so
the array will have to grow as I process the incoming data.

I also need to grab a value from my data stream, look it up in this array,
if its there, bump the value by one - if its not here, grow the array and
put a one to the value.

I'm trying to find out if this should be done in an array, a collection?, or
other.

From searching and reviewing all the sample code out there is confusing me I
guess.

Any help appreciated. Thanks, joe


 
Reply With Quote
 
 
 
 
Daniel Moth
Guest
Posts: n/a
 
      21st Nov 2004
See if a hashtable meets your needs:
http://msdn.microsoft.com/library/de...classtopic.asp

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"joe" <(E-Mail Removed)> wrote in message
news:uST$zT%(E-Mail Removed)...
>I am trying to track counts of values - I guess an 2-dimn array would be
>the
> way to go?
>
> Basically I want a string in the first position and an integer in the
> second:
>
> "This strValue", 5
> "That strValue", 21
> "Other strValue", 2
> ...
>
> and i don't know what the values are, nor how many values there will be,
> so
> the array will have to grow as I process the incoming data.
>
> I also need to grab a value from my data stream, look it up in this array,
> if its there, bump the value by one - if its not here, grow the array and
> put a one to the value.
>
> I'm trying to find out if this should be done in an array, a collection?,
> or
> other.
>
> From searching and reviewing all the sample code out there is confusing me
> I
> guess.
>
> Any help appreciated. Thanks, joe
>
>



 
Reply With Quote
 
joe
Guest
Posts: n/a
 
      21st Nov 2004
Thanks Daniel, this looks real promising.

I have figured out how to add my key/value pairs, how to display them later
(like that was tough to figure out with the help files) and how to lookup a
given key to verify that it exists.

But to update the counter each time its found, I'm not seeing. Does the Add
method search for a dup and allow an update if it does indeed exist? I
can't seem to find an answer to this one.

Thanks again!

"Daniel Moth" <(E-Mail Removed)> wrote in message
news:uBpblj%(E-Mail Removed)...
> See if a hashtable meets your needs:
>

http://msdn.microsoft.com/library/de...classtopic.asp
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
>
> "joe" <(E-Mail Removed)> wrote in message
> news:uST$zT%(E-Mail Removed)...
> >I am trying to track counts of values - I guess an 2-dimn array would be
> >the
> > way to go?
> >
> > Basically I want a string in the first position and an integer in the
> > second:
> >
> > "This strValue", 5
> > "That strValue", 21
> > "Other strValue", 2
> > ...
> >
> > and i don't know what the values are, nor how many values there will be,
> > so
> > the array will have to grow as I process the incoming data.
> >
> > I also need to grab a value from my data stream, look it up in this

array,
> > if its there, bump the value by one - if its not here, grow the array

and
> > put a one to the value.
> >
> > I'm trying to find out if this should be done in an array, a

collection?,
> > or
> > other.
> >
> > From searching and reviewing all the sample code out there is confusing

me
> > I
> > guess.
> >
> > Any help appreciated. Thanks, joe
> >
> >

>
>



 
Reply With Quote
 
joe
Guest
Posts: n/a
 
      21st Nov 2004
Ah, I found it. Thanks Daniel - this works like a charm!

"joe" <(E-Mail Removed)> wrote in message
news:uyKHAw%(E-Mail Removed)...
> Thanks Daniel, this looks real promising.
>
> I have figured out how to add my key/value pairs, how to display them

later
> (like that was tough to figure out with the help files) and how to lookup

a
> given key to verify that it exists.
>
> But to update the counter each time its found, I'm not seeing. Does the

Add
> method search for a dup and allow an update if it does indeed exist? I
> can't seem to find an answer to this one.
>
> Thanks again!
>
> "Daniel Moth" <(E-Mail Removed)> wrote in message
> news:uBpblj%(E-Mail Removed)...
> > See if a hashtable meets your needs:
> >

>

http://msdn.microsoft.com/library/de...classtopic.asp
> >
> > Cheers
> > Daniel
> > --
> > http://www.danielmoth.com/Blog/
> >
> >
> > "joe" <(E-Mail Removed)> wrote in message
> > news:uST$zT%(E-Mail Removed)...
> > >I am trying to track counts of values - I guess an 2-dimn array would

be
> > >the
> > > way to go?
> > >
> > > Basically I want a string in the first position and an integer in the
> > > second:
> > >
> > > "This strValue", 5
> > > "That strValue", 21
> > > "Other strValue", 2
> > > ...
> > >
> > > and i don't know what the values are, nor how many values there will

be,
> > > so
> > > the array will have to grow as I process the incoming data.
> > >
> > > I also need to grab a value from my data stream, look it up in this

> array,
> > > if its there, bump the value by one - if its not here, grow the array

> and
> > > put a one to the value.
> > >
> > > I'm trying to find out if this should be done in an array, a

> collection?,
> > > or
> > > other.
> > >
> > > From searching and reviewing all the sample code out there is

confusing
> me
> > > I
> > > guess.
> > >
> > > Any help appreciated. Thanks, joe
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
joe
Guest
Posts: n/a
 
      21st Nov 2004
HastTables can't be sorted ... doesn't appear that SortedList is supported
in the CF. How can I get around this? I need to display my key/values in
key-sorted order.


"Daniel Moth" <(E-Mail Removed)> wrote in message
news:uBpblj%(E-Mail Removed)...
> See if a hashtable meets your needs:
>

http://msdn.microsoft.com/library/de...classtopic.asp
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
>
> "joe" <(E-Mail Removed)> wrote in message
> news:uST$zT%(E-Mail Removed)...
> >I am trying to track counts of values - I guess an 2-dimn array would be
> >the
> > way to go?
> >
> > Basically I want a string in the first position and an integer in the
> > second:
> >
> > "This strValue", 5
> > "That strValue", 21
> > "Other strValue", 2
> > ...
> >
> > and i don't know what the values are, nor how many values there will be,
> > so
> > the array will have to grow as I process the incoming data.
> >
> > I also need to grab a value from my data stream, look it up in this

array,
> > if its there, bump the value by one - if its not here, grow the array

and
> > put a one to the value.
> >
> > I'm trying to find out if this should be done in an array, a

collection?,
> > or
> > other.
> >
> > From searching and reviewing all the sample code out there is confusing

me
> > I
> > guess.
> >
> > Any help appreciated. Thanks, joe
> >
> >

>
>



 
Reply With Quote
 
Daniel Moth
Guest
Posts: n/a
 
      21st Nov 2004
I guess you found the Item property for your previous question:
http://msdn.microsoft.com/library/de...sitemtopic.asp

For sorting there is a similar thread in the archives. Check it out:
http://groups.google.com/groups?hl=e...1ae9218&rnum=1

I would retrieve the Keys, sort them, and then iterate over the sorted keys
retrieving items from the hashtable.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"joe" <(E-Mail Removed)> wrote in message
news:%234etnZ$(E-Mail Removed)...
> HastTables can't be sorted ... doesn't appear that SortedList is
> supported
> in the CF. How can I get around this? I need to display my key/values in
> key-sorted order.
>
>
> "Daniel Moth" <(E-Mail Removed)> wrote in message
> news:uBpblj%(E-Mail Removed)...
>> See if a hashtable meets your needs:
>>

> http://msdn.microsoft.com/library/de...classtopic.asp
>>
>> Cheers
>> Daniel
>> --
>> http://www.danielmoth.com/Blog/
>>
>>
>> "joe" <(E-Mail Removed)> wrote in message
>> news:uST$zT%(E-Mail Removed)...
>> >I am trying to track counts of values - I guess an 2-dimn array would be
>> >the
>> > way to go?
>> >
>> > Basically I want a string in the first position and an integer in the
>> > second:
>> >
>> > "This strValue", 5
>> > "That strValue", 21
>> > "Other strValue", 2
>> > ...
>> >
>> > and i don't know what the values are, nor how many values there will
>> > be,
>> > so
>> > the array will have to grow as I process the incoming data.
>> >
>> > I also need to grab a value from my data stream, look it up in this

> array,
>> > if its there, bump the value by one - if its not here, grow the array

> and
>> > put a one to the value.
>> >
>> > I'm trying to find out if this should be done in an array, a

> collection?,
>> > or
>> > other.
>> >
>> > From searching and reviewing all the sample code out there is confusing

> me
>> > I
>> > guess.
>> >
>> > Any help appreciated. Thanks, joe
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
joe
Guest
Posts: n/a
 
      21st Nov 2004
> For sorting there is a similar thread in the archives. Check it out:
>

http://groups.google.com/groups?hl=e...1ae9218&rnum=1

Yes, I have been reviewing that thread and the accompanying codeproject
articles. But wow, just to sort a list that was a lot of stuff. I
digressed into basically what you lead me to below; testing it now. Maybe
this is exactly what the articles were talking about, but if so, he sure
took a round about way of explaining it (or maybe I'm slow on this sunday
afternoon -more probable).

>
> I would retrieve the Keys, sort them, and then iterate over the sorted

keys
> retrieving items from the hashtable.
>


Thanks Daniel, I think I got 'er working now. Much appreciated.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array vs. Collection RyanH Microsoft Excel Programming 7 24th Oct 2008 06:18 PM
VBA - array or collection literals? Marcus =?iso-8859-15?Q?Sch=F6neborn?= Microsoft Excel Programming 2 21st Sep 2007 08:52 PM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft ASP .NET 1 18th May 2007 10:24 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
Re: array vs. collection Kevin Spencer Microsoft ASP .NET 0 17th Jun 2004 02:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:31 PM.