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 3455254
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:35:31+00:00 2026-05-18T09:35:31+00:00

I am attempting to build a relatively complex data structure (for me). My goal

  • 0

I am attempting to build a relatively complex data structure (for me). My goal is to read words from text documents and index the words and some specific properties into a hash table. The table is constructed from a vector of vectors of structs: (vector < vector > vecName;). This much I have had luck with. Each unique word is hashed into an index location in the vector. The second dimension of the the vector (the vector of structs) stores info about the file being read and where the word is found in the file. For each file that I read, if I find a certain word multiple times, a count is incremented in the struct and a vector of structs with integers stores the info for all the locations that the word is stored in the file.

I have two items I would like assistance with:

  1. I’m curious if anyone has suggestions for a better data structure implementation than my suggestion. Would a class that contains some independent data members instead of this behemoth possibly be more useable?
  2. It appears that I have either a syntax error that is causing a compilation error or I am simply attempting to build a structure that the vector class doesn’t support.

Here are the cmpilation errors. All three errors refer to the vector of structs inside a struct:

‘class std::vector >’ has no member named ‘theLoc’
‘class std::vector >’ has no member named ‘theStart’
‘class std::vector >’ has no member named ‘theEnd’

If I tweak the code as EboMike suggests, the original errors go away but I then get:

I get a different error that I can’t post becase the editor thinks I’m posting hyperlinks. The summary is: *’Request for member ‘push_back’ in ‘testProps.wordProps::theWordLoc:theLoc, which is of non-class type ‘int’*

Here is my code and a link to a diagram (from my blog) of how I see the data structure:

http://iamkevinfrye.com/blog/wp-content/uploads/2010/10/MicroSearch-Hash-Table-Data-Structure-Diagram.png

#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

struct wordLoc
{
    int theLoc;                     // the location of the word in theFile
    int theStart;                   // the beginning of the sentence
    int theEnd;                     // the end of the sentence
};

struct wordProps                    // stores word info to be placed in array
{
    string  theFile;                // stores the file where theWord is found
    int theCount;                   // increments with each occurence of theWord
    vector <wordLoc> theWordLoc;    // stores the wordLoc info for each occurence of theWord
};

int main()
{    
    int Tsize = 20000;

    wordProps testProps;
    testProps.theFile = "test1";
    testProps.theCount = 1;
    testProps.theWordLoc.theLoc.push_back(200);
    testProps.theWordLoc.theStart.push_back(1);
    testProps.theWordLoc.theEnd.push_back(15);

    vector < vector <wordProps> > theWordProps;
    theWordProps.resize(Tsize);

    theWordProps[0].push_back(testProps);

    cout << "index[0] = " << theWordProps[0].front().theFile << endl;
    cout << "index[0] = " << theWordProps[0].front().theCount << endl;
    cout << "index[0] = " << theWordProps[0].front().theWordLoc[0].theLoc << endl;
    cout << "index[0] = " << theWordProps[0].front().theWordLoc[0].theStart << endl;
    cout << "index[0] = " << theWordProps[0].front().theWordLoc[0].theEnd << endl;
    cout << "size of theWordProps[0] = " << theWordProps[0].size();

    cout << endl;
}
  • 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-05-18T09:35:32+00:00Added an answer on May 18, 2026 at 9:35 am

    I don’t know about design choice of the data structure apart from making it a hasmap but your code is almost correct!

    Check out my comments:

    int main()
    {    
        int Tsize = 20000;
    
        wordProps testProps;
        testProps.theFile = "test1";
        testProps.theCount = 1;
    
        // create your wordLoc object
        wordLoc wl;
        wl.theLoc = 200;
        wl.theStart = 1;
        wl.theEnd = 15;
    
        // put it into the vector
        testProps.theWordLoc.push_back(wl);
    
        vector < vector <wordProps> > theWordProps;
        theWordProps.resize(Tsize);
    
        theWordProps[0].push_back(testProps);
    
        cout << "index[0] = " << theWordProps[0].front().theFile << endl;
        cout << "index[0] = " << theWordProps[0].front().theCount << endl;
        cout << "index[0] = " << theWordProps[0].front().theWordLoc[0].theLoc << endl;
        cout << "index[0] = " << theWordProps[0].front().theWordLoc[0].theStart << endl;
        cout << "index[0] = " << theWordProps[0].front().theWordLoc[0].theEnd << endl;
        cout << "size of theWordProps[0] = " << theWordProps[0].size();
    
        cout << endl;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to build a simple method that creates an XML file from
Hopefully some Custom Control Designers/Builders can help I'm attempting to build my first custom
Context: So, I am attempting to build a ridiculously complex domain model. Talking with
I am relatively new to both WPF and NHibernate and attempting to build an
I am attempting to pull some information from my tnsnames file using regex. I
I am attempting to build some classes so that I can deserialise an XML
I'm attempting to create a custom calendar control that inherits from ASP.Net's built in
Attempting to print out a list of values from 2 different variables that are
Attempting to deploy a MOSS solution to a UAT server from dev server for
When attempting to compile my C# project, I get the following error: 'C:\Documents and

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.