commit 9abc0096ac7454ef6b0bf9eede2f47d6493fe03f
parent c57c80e7e0ce5cc57c605b39e63c2a1af1dc2437
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date: Thu, 20 Jun 2024 02:00:35 -0300
create function `getBarrioPorNombre`
Diffstat:
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/main.cpp b/main.cpp
@@ -56,7 +56,25 @@ size_t getTokens(std::string line, std::vector<std::string> &tokens) {
void delSurroundingChar(std::string &str, char c) {
str.erase(0, 1);
str[str.size() - 1] = '\0';
-}
+}
+
+// busca el barrio en la lista de barrios, si no lo encuentra devuelve NULL
+Barrio *getBarrioPorNombre(std::string nombre, List<Barrio*> *barrios) {
+ if(barrios == NULL) {
+ return NULL;
+ }
+
+ Barrio *res = NULL;
+
+ barrios->startCursor();
+ while(barrios->forwardCursor()) {
+ if(barrios->getCursorData()->getNombre() == nombre) {
+ res = barrios->getCursorData();
+ }
+ }
+
+ return res;
+}
int main (void) {
std::ifstream inputFile;