#include "DependencyStructure.h" DependencyStructure::DependencyStructure(void) { } DependencyStructure::~DependencyStructure(void) { } /* Add a WordItem to the vector of verticies and return the WordItem */ int DependencyStructure::AddWord(WordItem w) { Verticies.push_back(w); return Verticies.size()-1; } /* Find a WordItem in the verticies which is the same as the the target WordItem ** and return the WordItem */ int DependencyStructure::Find(WordItem target) { for (int i = 0; i < Verticies.size(); i++) { if (Verticies[i] == target) return i; } return -1; } /* Find a WordItem in the verticies which is the same as the target WordItem and ** has a WordItem that depends on it which is the same as a WordItem that depends ** on the target WordItem. Return the WordItem that's been found. */ int DependencyStructure::Find(WordItem target, vector dependants) { for (int i = 0; i < Verticies.size(); i++) { // go through the verticies if (Verticies[i] == target) { // to find a WordItem that is the same as the target for (int j = 0; j < Edges.size(); j++) { // Go through the edges if (Verticies[Edges[j].parent].operator ==(Verticies[i])) { // To find children of the vertex for (int k = 0; k < dependants.size(); k++) { // Go through the dependants of the target if (Verticies[Edges[j].child].operator ==(dependants[k])) { // to see if they are the same as the dependants of the WordItem return i; } } } } } } return -1; }