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. Find unique strings for a string array

Find unique strings for a string array

Scheduled Pinned Locked Moved C#
data-structurestutorialquestion
44 Posts 11 Posters 5 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.
  • D Dragonfly_Lee

    George_George wrote:

    BTW: if LINQ is slow, why people will use LINQ?

    I think Mark is right. We can get the benefits from LINQ for integrating the data and object. But I am not sure about the performance of LINQ. Though I do believe Mircosoft would make greate efforts to improve it.

    LuckyBoy

    G Offline
    G Offline
    George_George
    wrote on last edited by
    #32

    In my experience and other guys besides me, the performnace feedback of LINQ is bad. :-) What about yours? regards, George

    D 1 Reply Last reply
    0
    • L Lost User

      Sounds to me like you should be using a set data structure, if you never need the duplicate strings.

      At university studying Software Engineering - if i say this line to girls i find they won't talk to me Dan

      G Offline
      G Offline
      George_George
      wrote on last edited by
      #33

      Thanks Dan! But there is no such data structure in .Net, correct? regards, George

      L 1 Reply Last reply
      0
      • C Christian Graus

        public class set { private List theList; public bool Add(T item) { if (theList.Contains(item)) return false; theList.Add(item); return true; } } This is the start of a set class, a container that only contains one of any object.

        Christian Graus Driven to the arms of OSX by Vista.

        G Offline
        G Offline
        George_George
        wrote on last edited by
        #34

        Thanks Christian, I like your idea. I am surprised why there is no built-in Set class in .Net. :-) regards, George

        1 Reply Last reply
        0
        • D dan sh

          May be Array.FindAll can help you. Check out MSDN for it. Another way could be: 1. Create a list/hashtable. Then loop through the array. 2. Check if the element exists in the list/hashtable. 3. If it does its a duplicate value. Remove it from array. 4. If it doesnt add it to the list/hashtable.

          C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void "Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding

          G Offline
          G Offline
          George_George
          wrote on last edited by
          #35

          Hi d@nish, I have studied related MSDN page about Array.FindAll, but I do not think it could help me in my solution. Do you have any pesudo code to show your idea of using Array.FindAll to make a unique string array? regards, George

          1 Reply Last reply
          0
          • B Brij

            Generic does means only List.We have some more like Dictionary,SortedList,Queue,Stack but list suits your requirement best.

            Cheers!! Brij

            G Offline
            G Offline
            George_George
            wrote on last edited by
            #36

            Thanks for your clarification, Brij! regards, George

            1 Reply Last reply
            0
            • P PIEBALDconsult

              Operators.

              G Offline
              G Offline
              George_George
              wrote on last edited by
              #37

              Could you show more description please? What operators do you think your class provides has advantages over .Net built-in ones? regards, George

              1 Reply Last reply
              0
              • G George_George

                Thanks Dan! But there is no such data structure in .Net, correct? regards, George

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #38

                Hey There isnt an inbuilt one but take a look at this post, or you could even implement your own if you are bored and have some time :P http://stackoverflow.com/questions/10458/is-there-a-set-data-structure-in-net[^] Hope that helps

                At university studying Software Engineering - if i say this line to girls i find they won't talk to me Dan

                G 1 Reply Last reply
                0
                • G George_George

                  In my experience and other guys besides me, the performnace feedback of LINQ is bad. :-) What about yours? regards, George

                  D Offline
                  D Offline
                  Dragonfly_Lee
                  wrote on last edited by
                  #39

                  In fact, I did not use LINQ quite often in my project. Hence I could not give you any comment about performance of LINQ, especially without investigating from performance tool. However, I have to admit the creativity of LINQ. For a certain degree, it presents the .net technology tendency-integrate data. Although maybe the final goal is ambitious and full of issues, such as performance, complexity, nobody would ignore the benefits form LINQ. :)

                  LuckyBoy

                  G 1 Reply Last reply
                  0
                  • L Lost User

                    Hey There isnt an inbuilt one but take a look at this post, or you could even implement your own if you are bored and have some time :P http://stackoverflow.com/questions/10458/is-there-a-set-data-structure-in-net[^] Hope that helps

                    At university studying Software Engineering - if i say this line to girls i find they won't talk to me Dan

                    G Offline
                    G Offline
                    George_George
                    wrote on last edited by
                    #40

                    Thanks Dan! Good stuff! regards, George

                    1 Reply Last reply
                    0
                    • D Dragonfly_Lee

                      In fact, I did not use LINQ quite often in my project. Hence I could not give you any comment about performance of LINQ, especially without investigating from performance tool. However, I have to admit the creativity of LINQ. For a certain degree, it presents the .net technology tendency-integrate data. Although maybe the final goal is ambitious and full of issues, such as performance, complexity, nobody would ignore the benefits form LINQ. :)

                      LuckyBoy

                      G Offline
                      G Offline
                      George_George
                      wrote on last edited by
                      #41

                      Hi LuckyBoy, I think ising ADO.Net is fine enough, why bothering using LINQ? :-) regards, George

                      D 1 Reply Last reply
                      0
                      • G George_George

                        Hi LuckyBoy, I think ising ADO.Net is fine enough, why bothering using LINQ? :-) regards, George

                        D Offline
                        D Offline
                        Dragonfly_Lee
                        wrote on last edited by
                        #42

                        Well, Language Integrated Query, maybe to provide a common QUERY method for various data source from different domains, such as ADO.net, XML, SQL server, is the way how microsoft simplify the access for data and object. But it is still young, so let us try to be nice and patient.

                        Tan Li I Love KongFu~

                        G 1 Reply Last reply
                        0
                        • D Dragonfly_Lee

                          Well, Language Integrated Query, maybe to provide a common QUERY method for various data source from different domains, such as ADO.net, XML, SQL server, is the way how microsoft simplify the access for data and object. But it is still young, so let us try to be nice and patient.

                          Tan Li I Love KongFu~

                          G Offline
                          G Offline
                          George_George
                          wrote on last edited by
                          #43

                          Thanks Tan Li! regards, George

                          D 1 Reply Last reply
                          0
                          • G George_George

                            Thanks Tan Li! regards, George

                            D Offline
                            D Offline
                            Dragonfly_Lee
                            wrote on last edited by
                            #44

                            Welcome~

                            Tan Li I Love KongFu~

                            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