Demo entry 6338588

VVec.h

   

Submitted by anonymous on Dec 13, 2016 at 21:11
Language: C++. Code size: 1.8 kB.

/*
 * Vertex Vector Class (string keys):  This vector is a vector of nodes, each 
 * identified by its key (a string), and containing a list of vertex nodes.  
 * This class is primarily used to hold the adjacency list.
 */

#ifndef VVec_H_
#define VVec_H_

#include <iostream>
 
#include <vector>
#include <string>


struct Vertex{
	std::string	pathName; //include path name
	std::string	stuName; //just student name
};


struct Node{
        std::string			key; 	//stores key name
        std::vector<Vertex> 		vertices; //stores values
};

class VVec{

public:
	//constructor 
        VVec();

        //destuctor 
        ~VVec();

        //check if a vector holds a specific key and return the index of the
        //key if found, and a null value (-999) if not found
        int 	hasKey(std::string k);

        //check if the vector held by a node holds a specific value 
        int 	hasValue(std::string k, std::string v);

        //add key to the vector
        bool 	addKey(std::string k);

        //add value to a key's vector
        bool 	addValue(std::string k, std::string v, std::string v_short);

        //print keys held in vector, can be used for 'ls', and 'lc' commands
        void 	printKeys();

        //print values held in a node, can be used for 'taed' command
        void 	printValues(std::string k);

        //get size of vector
        int 	getSizeKeys();

        //get size of vector in a key;
        int 	getSizeValues(int k_index);

        //get name of key at an index;
        std::string getKeyName(int k_index);

        //get name of value in key's values list at specific index
        std::string getValueName(int k_index, int v_index);

        //get vertex
        Vertex	getVertex(int k_index, int v_index);


private:

        std::vector<Node>	KeyVector;

};

#endif /* VVec_H_ */

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).