Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7984937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:25:48+00:00 2026-06-04T11:25:48+00:00

this code is just a test to find duplicates of a vector and remove

  • 0

this code is just a test to find duplicates of a vector and remove them ,while removing the correspoding objects of 2 other vectors

This gives as output an Arrayoutofindex in line 3.Do you have any suggestions?

        for (int k = 0 ; k < vA.size() ; k++)
            {                       
                Object a = vA.elementAt(0);
                Object b = vA.elementAt(k);
                if(a == b && k!=0)
                {
                int duplicate = vA.indexOf(b);
                vA.removeElementAt(duplicate);
                vB.removeElementAt(duplicate);
                vC.removeElementAt(duplicate);                    
                }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:25:50+00:00Added an answer on June 4, 2026 at 11:25 am

    for (int k = 0 ; k <= vA.size() ; k++)
    k should run only from 0 to va.size() - 1 because it is zero-based, i.e. the first index is 0. Rewrite the loop statement as:

    for (int k = 0 ; k < vA.size() ; k++)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this test code that just saves an XML file to a folder.
I have just come across this code: function test(){ //... if ( $profilerule ==
just trying to test for equality in this piece of code, but getting a
I just saw this code while studying the wordpress source code (PHP), You can
Can anybody help with this code I just don't know where I am going
I am working on const-correctness of my code and just wondered why this code
this code in my plugin used to work just fine: jQuery('#embedded_obj', context).get(0).getVersion(); and the
I just found this code in reflector in the .NET base libraries... if (this._PasswordStrengthRegularExpression
This code works on one of my dev boxes (using JQ v1.3.2.) I just
is it just me or this code in Programming Pearls is wrong (quicksort wants

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.