Skip to main content
deleted 202 characters in body
Source Link
Fattie
  • 9.8k
  • 76
  • 455
  • 769

I have a list of about 500 strings "joe" "john" "jack" ... "jan"

I only need to find the ordinal.

In my example, the list will never be changed.

One could just put them in a list and IndexOf

ll.Add("joe") ll.Add("john") ... ll.Add("jan") ll.IndexOf("jib") is 315 

or you can put them in a dictionary, using the ordinal integers as the values,

dd.Add("joe", 1) dd.Add("john", 2) dd.Add("jack", 3) ... dd.Add("jan", 571) dd["jib"] is 315 

FTR the strings are 3 to 8 characters long. FTR this is in a Unity, hence Mono, milieu.

  1. Purely for performance, is one approach generally preferable?

1b) Indeed, I found a number of analysis of this nature: http://www.dotnetperls.com/dictionary-time (google for a number of similar analyses). Does this apply to the situation I describe or am I off here?

  1. Regarding which is better in a general development engineering sense. (Completely set aside performance.) It seems to me both have obvious advantages and disadvantages; neither is very elegant.

  2. It's a shame there isn't a "HashSetLikeThingWithOrdinality" type of facility - if I'm missing an obvious please let us know. Indeed, this seems like a fairly common, basic, collections use case - "get the ordinal of some strings" - perhaps I am completely missing something obvious.

    It's a shame there isn't a "HashSetLikeThingWithOrdinality" type of facility - if I'm missing an obvious please let us know. Indeed, this seems like a fairly common, basic, collections use case - "get the ordinal of some strings" - perhaps I am completely missing something obvious.

I have a list of about 500 strings "joe" "john" "jack" ... "jan"

I only need to find the ordinal.

In my example, the list will never be changed.

One could just put them in a list and IndexOf

ll.Add("joe") ll.Add("john") ... ll.Add("jan") ll.IndexOf("jib") is 315 

or you can put them in a dictionary, using the ordinal integers as the values,

dd.Add("joe", 1) dd.Add("john", 2) dd.Add("jack", 3) ... dd.Add("jan", 571) dd["jib"] is 315 

FTR the strings are 3 to 8 characters long. FTR this is in a Unity, hence Mono, milieu.

  1. Purely for performance, is one approach generally preferable?

1b) Indeed, I found a number of analysis of this nature: http://www.dotnetperls.com/dictionary-time (google for a number of similar analyses). Does this apply to the situation I describe or am I off here?

  1. Regarding which is better in a general development engineering sense. (Completely set aside performance.) It seems to me both have obvious advantages and disadvantages; neither is very elegant.

  2. It's a shame there isn't a "HashSetLikeThingWithOrdinality" type of facility - if I'm missing an obvious please let us know. Indeed, this seems like a fairly common, basic, collections use case - "get the ordinal of some strings" - perhaps I am completely missing something obvious.

I have a list of about 500 strings "joe" "john" "jack" ... "jan"

I only need to find the ordinal.

In my example, the list will never be changed.

One could just put them in a list and IndexOf

ll.Add("joe") ll.Add("john") ... ll.Add("jan") ll.IndexOf("jib") is 315 

or you can put them in a dictionary, using the ordinal integers as the values,

dd.Add("joe", 1) dd.Add("john", 2) dd.Add("jack", 3) ... dd.Add("jan", 571) dd["jib"] is 315 

FTR the strings are 3 to 8 characters long. FTR this is in a Unity, hence Mono, milieu.

  1. Purely for performance, is one approach generally preferable?

1b) Indeed, I found a number of analysis of this nature: http://www.dotnetperls.com/dictionary-time (google for a number of similar analyses). Does this apply to the situation I describe or am I off here?

  1. It's a shame there isn't a "HashSetLikeThingWithOrdinality" type of facility - if I'm missing an obvious please let us know. Indeed, this seems like a fairly common, basic, collections use case - "get the ordinal of some strings" - perhaps I am completely missing something obvious.
added 48 characters in body
Source Link
Fattie
  • 9.8k
  • 76
  • 455
  • 769

I have a list of about 500 strings "joe" "john" "jack" ... "jan"

I only need to find the ordinal.

In my example, the list will never be changed.

One could just put them in a list and IndexOf

ll.Add("joe") ll.Add("john") ... ll.Add("jan") ll.IndexOf("jib") is 315 

or you can put them in a dictionary, using the ordinal integers as the values,

dd.Add("joe", 1) dd.Add("john", 2) dd.Add("jack", 3) ... dd.Add("jan", 571) dd["jib"] is 315 

FTR the strings are 3 to 8 characters long. FTR this is in a Unity, hence Mono, milieu.

  1. Purely for performance, is one approach generally preferable?

1b) Indeed, I found a number of analysis of this nature: http://www.dotnetperls.com/dictionary-time (google for a number of similar analyses). Does this apply to the situation I describe or am I off here?

  1. Regarding which is better in a general development engineering sense. (Completely set aside performance.) It seems to me both have obvious advantages and disadvantages; neither is very elegant. (It's a shame there isn't a "HashSetLikeThingWithOrdinality" type of facility.)

    Regarding which is better in a general development engineering sense. (Completely set aside performance.) It seems to me both have obvious advantages and disadvantages; neither is very elegant.

  2. It's a shame there isn't a "HashSetLikeThingWithOrdinality" type of facility - if I'm missing an obvious please let us know. Indeed, this seems like a fairly common, basic, collections use case - "get the ordinal of some strings" - perhaps I am completely missing something obvious.

Indeed, this seems like a fairly common, basic, collections use case - "get the ordinal of some strings" - perhaps I am completely missing something obvious.

I have a list of about 500 strings "joe" "john" "jack" ... "jan"

I only need to find the ordinal.

In my example, the list will never be changed.

One could just put them in a list and IndexOf

ll.Add("joe") ll.Add("john") ... ll.Add("jan") ll.IndexOf("jib") is 315 

or you can put them in a dictionary, using the ordinal integers as the values,

dd.Add("joe", 1) dd.Add("john", 2) dd.Add("jack", 3) ... dd.Add("jan", 571) dd["jib"] is 315 

FTR the strings are 3 to 8 characters long. FTR this is in a Unity, hence Mono, milieu.

  1. Purely for performance, is one approach generally preferable?

1b) Indeed, I found a number of analysis of this nature: http://www.dotnetperls.com/dictionary-time (google for a number of similar analyses). Does this apply to the situation I describe or am I off here?

  1. Regarding which is better in a general development engineering sense. (Completely set aside performance.) It seems to me both have obvious advantages and disadvantages; neither is very elegant. (It's a shame there isn't a "HashSetLikeThingWithOrdinality" type of facility.)

Indeed, this seems like a fairly common, basic, collections use case - "get the ordinal of some strings" - perhaps I am completely missing something obvious.

I have a list of about 500 strings "joe" "john" "jack" ... "jan"

I only need to find the ordinal.

In my example, the list will never be changed.

One could just put them in a list and IndexOf

ll.Add("joe") ll.Add("john") ... ll.Add("jan") ll.IndexOf("jib") is 315 

or you can put them in a dictionary, using the ordinal integers as the values,

dd.Add("joe", 1) dd.Add("john", 2) dd.Add("jack", 3) ... dd.Add("jan", 571) dd["jib"] is 315 

FTR the strings are 3 to 8 characters long. FTR this is in a Unity, hence Mono, milieu.

  1. Purely for performance, is one approach generally preferable?

1b) Indeed, I found a number of analysis of this nature: http://www.dotnetperls.com/dictionary-time (google for a number of similar analyses). Does this apply to the situation I describe or am I off here?

  1. Regarding which is better in a general development engineering sense. (Completely set aside performance.) It seems to me both have obvious advantages and disadvantages; neither is very elegant.

  2. It's a shame there isn't a "HashSetLikeThingWithOrdinality" type of facility - if I'm missing an obvious please let us know. Indeed, this seems like a fairly common, basic, collections use case - "get the ordinal of some strings" - perhaps I am completely missing something obvious.

deleted 9 characters in body
Source Link
Fattie
  • 9.8k
  • 76
  • 455
  • 769

I have an ordereda list of about 500 strings "joe" "john" "jack" ... "jan"

I only need to find the ordinal.

In my example, the list will never be changed.

One could just put them in a list and IndexOf

ll.Add("joe") ll.Add("john") ... ll.Add("jan") ll.IndexOf("jib") is 315 

or you can put them in a dictionary, using the ordinal integers as the values,

dd.Add("joe", 1) dd.Add("john", 2) dd.Add("jack", 3) ... dd.Add("jan", 571) dd["jib"] is 315 

FTR the strings are 3 to 8 characters long. FTR this is in a Unity, hence Mono, milieu.

  1. Purely for performance, is one approach generally preferable?

1b) Indeed, I found a number of analysis of this nature: http://www.dotnetperls.com/dictionary-time (google for a number of similar analyses). Does this apply to the situation I describe or am I off here?

  1. Regarding which is better in a general development engineering sense. (Completely set aside performance.) It seems to me both have obvious advantages and disadvantages; neither is very elegant. (It's a shame there isn't a "HashSetLikeThingWithOrdinality" type of facility.)

Indeed, this seems like a fairly common, basic, collections use case - "get the ordinal of some strings" - perhaps I am completely missing something obvious.

I have an ordered list of about 500 strings "joe" "john" "jack" ... "jan"

I only need to find the ordinal.

In my example, the list will never be changed.

One could just put them in a list and IndexOf

ll.Add("joe") ll.Add("john") ... ll.Add("jan") ll.IndexOf("jib") is 315 

or you can put them in a dictionary, using the ordinal integers as the values,

dd.Add("joe", 1) dd.Add("john", 2) dd.Add("jack", 3) ... dd.Add("jan", 571) dd["jib"] is 315 

FTR the strings are 3 to 8 characters long. FTR this is in a Unity, hence Mono, milieu.

  1. Purely for performance, is one approach generally preferable?

1b) Indeed, I found a number of analysis of this nature: http://www.dotnetperls.com/dictionary-time (google for a number of similar analyses). Does this apply to the situation I describe or am I off here?

  1. Regarding which is better in a general development engineering sense. (Completely set aside performance.) It seems to me both have obvious advantages and disadvantages; neither is very elegant. (It's a shame there isn't a "HashSetLikeThingWithOrdinality" type of facility.)

Indeed, this seems like a fairly common, basic, collections use case - "get the ordinal of some strings" - perhaps I am completely missing something obvious.

I have a list of about 500 strings "joe" "john" "jack" ... "jan"

I only need to find the ordinal.

In my example, the list will never be changed.

One could just put them in a list and IndexOf

ll.Add("joe") ll.Add("john") ... ll.Add("jan") ll.IndexOf("jib") is 315 

or you can put them in a dictionary, using the ordinal integers as the values,

dd.Add("joe", 1) dd.Add("john", 2) dd.Add("jack", 3) ... dd.Add("jan", 571) dd["jib"] is 315 

FTR the strings are 3 to 8 characters long. FTR this is in a Unity, hence Mono, milieu.

  1. Purely for performance, is one approach generally preferable?

1b) Indeed, I found a number of analysis of this nature: http://www.dotnetperls.com/dictionary-time (google for a number of similar analyses). Does this apply to the situation I describe or am I off here?

  1. Regarding which is better in a general development engineering sense. (Completely set aside performance.) It seems to me both have obvious advantages and disadvantages; neither is very elegant. (It's a shame there isn't a "HashSetLikeThingWithOrdinality" type of facility.)

Indeed, this seems like a fairly common, basic, collections use case - "get the ordinal of some strings" - perhaps I am completely missing something obvious.

added 65 characters in body
Source Link
Fattie
  • 9.8k
  • 76
  • 455
  • 769
Loading
Source Link
Fattie
  • 9.8k
  • 76
  • 455
  • 769
Loading