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 / C++ / MFC
  4. search vectors

search vectors

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++javagraphicsregex
6 Posts 2 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.
  • K Offline
    K Offline
    kaminem
    wrote on last edited by
    #1

    Hi guys, I have two vectors of string and I'm looking for an easy way to find the first vector sequence or sub-sequence into the first one for example: Vect_1 < "JAVA", "ADA", "C", "C++", "C#"> Vect_2 < "C++", "C#"> search vect_2 sequence in vect_1 will return vect_1 position 3 and match length 2 Vect_1 < "JAVA", "ADA", "C", "C++", "C#"> Vect_2 < "JAVA", "C#"> search vect_2 sequence in vect_1 will return vect_1 position 0 and match length 1 thanks for any idea, suggestion

    D 1 Reply Last reply
    0
    • K kaminem

      Hi guys, I have two vectors of string and I'm looking for an easy way to find the first vector sequence or sub-sequence into the first one for example: Vect_1 < "JAVA", "ADA", "C", "C++", "C#"> Vect_2 < "C++", "C#"> search vect_2 sequence in vect_1 will return vect_1 position 3 and match length 2 Vect_1 < "JAVA", "ADA", "C", "C++", "C#"> Vect_2 < "JAVA", "C#"> search vect_2 sequence in vect_1 will return vect_1 position 0 and match length 1 thanks for any idea, suggestion

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Are you simply wanting to know how to search a vector?

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      K 1 Reply Last reply
      0
      • D David Crow

        Are you simply wanting to know how to search a vector?

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        K Offline
        K Offline
        kaminem
        wrote on last edited by
        #3

        it's a little bit more complicated I'm looking for a way to search a vector into an other vector std::set_intersection can do it, but in my case I have to respect the order of the sequence :doh:

        D 1 Reply Last reply
        0
        • K kaminem

          it's a little bit more complicated I'm looking for a way to search a vector into an other vector std::set_intersection can do it, but in my case I have to respect the order of the sequence :doh:

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          kaminem wrote:

          ...search a vector into an other vector

          What does this mean? :confused:

          "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          K 2 Replies Last reply
          0
          • D David Crow

            kaminem wrote:

            ...search a vector into an other vector

            What does this mean? :confused:

            "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            K Offline
            K Offline
            kaminem
            wrote on last edited by
            #5

            I want to search vect_2 into Vect_1 for example Vect_1 < "JAVA", "ADA", "C", "C++", "C#"> Vect_2 < "C++", "C#"> here vect_1 contain all vect_2 elemnts and in the some order but if I don't find the entire sequence I should look for a subsequence too (and this is my big pb) I'm trying to avoid the use of for loop

            1 Reply Last reply
            0
            • D David Crow

              kaminem wrote:

              ...search a vector into an other vector

              What does this mean? :confused:

              "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              K Offline
              K Offline
              kaminem
              wrote on last edited by
              #6

              solution use of std::search

              How to use google - fun[^]

              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