How to fill a vector of lists?


I'm trying to put ascii codes and names into a vector of lists: So ideally what it would be like is this:

<strong>97:</strong> "awesome", "all"

<strong>98:</strong> "best" , "boom", "bomb"

<strong>99:</strong> "cat"

I have

class index_table { public: index_table() { table.resize(128);} void insert(string &, int); private: class entry { //Subclass string word; vector <int> line; } vector< list <entry > > table;

So how can I correctly put these words and ascii number into the vector of lists?

In main I've tried some syntax, but it's not working:

void index_table :: insert ( string & word, int num) //This is the code for "cat" and "99" { entry obj; //This is the part I'm not sure about. How do I enter each word and num into the vector < list < entry >> table }

Hopefully I made this clear enough. To sum up, I'm confused on how a vector < list < entry > > table works. Or rather, how will I be able to store my number and words in it correctly?


You are looking for data structure to hold the following:<br /> ID ~> list of entry objects<br /> ID ~> another list...

Yet the following type of table was wrong decision:

vector< list <entry > > table;

In case those numbers are unique indeed, it would be much wiser to use <a href="http://en.cppreference.com/w/cpp/container/map" rel="nofollow">std::map</a>:

std::map<int, std::list<entry> > table;

or in C++11 even <a href="http://en.cppreference.com/w/cpp/container/unordered_map" rel="nofollow">std::unordered_map</a>


  • react split panel resize
  • Using $this when not in object context
  • PHP - How to update data to MySQL when click a radio button
  • How do I fake an specific browser client when using Java's Net library?
  • How reduce the height of an mschart by breaking up the y-axis
  • MySQL WHERE-condition in procedure ignored
  • Join two tables and save into third-sql
  • Perl system calls when running as another user using sudo
  • How to handle AllServersUnavailable Exception
  • How to set my toolbar fixed while scrolling android
  • Javascript + PHP Encryption with pidCrypt
  • VBA Convert delimiter text file to Excel
  • Rearranging Cells in UITableView Bug & Saving Changes
  • AT Commands to Send SMS not working in Windows 8.1
  • Circular dependency while pushing http interceptor
  • Cannot Parse HTML Data Using Android / JSOUP
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • Linker errors when using intrinsic function via function pointer
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Getting Messege Twice Using IMvxMessenger
  • Java static initializers and reflection
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • apache spark aggregate function using min value
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • Sorting a 2D array using the second column C++
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How can i traverse a binary tree from right to left in java?
  • How to Embed XSL into XML
  • failed to connect to specific WiFi in android programmatically
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal
  • How can I use threading to 'tick' a timer to be accessed by other threads?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize