title: Inserting elements into 2D vector
body: <p>so I'm creating a class that implements an adjacency list. Currently in my class definition I initialized two vectors:</p>
  
  <pre><code>vector&lt;vector&lt;int&gt;&gt; adjList;
  vector&lt;int&gt; neighbors;
  </code></pre>
  
  <p>and I declared two functions that I plan to use to make it:</p>
  
  <pre><code>bool constructAdjList();
  bool insertIntoAdjList(int, int);
  </code></pre>
  
  <p>It's getting difficult wrapping my head around 2D vectors. I understand that it is essentially a vector of vectors, but I'm confused about how to insert a new value into one of the "subvectors". For example, I am able to create an adjacency list in createAdjList that is empty with the following loop:</p>
  
  <pre><code>for (int i = 0; i &lt; numOfValues; i++){
      neighbors.push_back(0);
      adjList.push_back(neighbors);
      neighbors.clear();
  }
  </code></pre>
  
  <p>But how can I say, push_back the value 5 to the 4th vector in adjList, which would be represented in my insertIntoAdjList function as </p>
  
  <pre><code>insertIntoAdjList(4, 5);
  </code></pre>
  
  <p>I know I can access a specific value in a 2D vector by saying adjList[4][1], but how can I push one onto it?</p>
  
  <p>Thanks!</p>