Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ArrayList comparsion

ArrayList comparsion

Scheduled Pinned Locked Moved C#
questionhelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    azusakt
    wrote on last edited by
    #1

    Hi all, I have 3 ArrayList, each of them stored some string color name, I want to ask how can I check any duplicated strings between them? Ofcourse, I can load all strings from one arrayList, and then use ArrayList.Contains(string) to check. however, any fast way to check this ?? Can I only use ArrayList.Contains() to compare with other ArrayList directly? Thanks for help~~

    S L D 3 Replies Last reply
    0
    • A azusakt

      Hi all, I have 3 ArrayList, each of them stored some string color name, I want to ask how can I check any duplicated strings between them? Ofcourse, I can load all strings from one arrayList, and then use ArrayList.Contains(string) to check. however, any fast way to check this ?? Can I only use ArrayList.Contains() to compare with other ArrayList directly? Thanks for help~~

      S Offline
      S Offline
      sreejith ss nair
      wrote on last edited by
      #2

      hi, ArrayList impliments few interfaces like IList,ICollection,IEnumerable,ICloneable by default. Suppose if you want to compare the element of arraylist you need to impliment IComparer interface. This contain one abstract method called Compare. ************************** S r e e j i t h N a i r **************************

      1 Reply Last reply
      0
      • A azusakt

        Hi all, I have 3 ArrayList, each of them stored some string color name, I want to ask how can I check any duplicated strings between them? Ofcourse, I can load all strings from one arrayList, and then use ArrayList.Contains(string) to check. however, any fast way to check this ?? Can I only use ArrayList.Contains() to compare with other ArrayList directly? Thanks for help~~

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        azusakt wrote: however, any fast way to check this ?? If you want fast lookups and have unique elements, I suggest you use a Hashtable instead :) top secret xacc-ide 0.0.1

        1 Reply Last reply
        0
        • A azusakt

          Hi all, I have 3 ArrayList, each of them stored some string color name, I want to ask how can I check any duplicated strings between them? Ofcourse, I can load all strings from one arrayList, and then use ArrayList.Contains(string) to check. however, any fast way to check this ?? Can I only use ArrayList.Contains() to compare with other ArrayList directly? Thanks for help~~

          D Offline
          D Offline
          Danny Rodriguez
          wrote on last edited by
          #4

          azusakt wrote: I have 3 ArrayList, each of them stored some string color name, I want to ask how can I check any duplicated strings between them? first off - why do you have 3 arraylist which seem to be related to eachother - wont 1 suffice? azusakt wrote: Ofcourse, I can load all strings from one arrayList, and then use ArrayList.Contains(string) to check. however, any fast way to check this ?? Can I only use ArrayList.Contains() to compare with other ArrayList directly? you might consider changing your datastructure to something that provides constant time mechanisms.. an arraylist is basic - some of the operations performed on it - (i think :D ) are not necessarily constant time complexity. how about something that using a hashing function of some sort ? like for example if you were to have 3 hashtables you could simply do a containskey which is constant time on thme ... you might want rethink what you are doing though - can you suffice with just 1 and then pass a reference to the remain parts of your program that require this datastructure? Danny!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups