fork download
  1. /*
  2.  * <one line to give the library's name and an idea of what it does.>
  3.  * Copyright (C) 2013 <copyright holder> <email>
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Lesser General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2.1 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13.  * Lesser General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Lesser General Public
  16.  * License along with this library; if not, write to the Free Software
  17.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18.  *
  19.  */
  20.  
  21. #pragma once
  22.  
  23. #include "../tree_binary.hpp"
  24. #include "../../error.hpp"
  25.  
  26. namespace tree {
  27.  
  28. data_t& BinaryTree::find(key_t key) {
  29. if(!root_.is_not_leaf()) {
  30. throw not_found_exception(key);
  31. }
  32.  
  33. element_t* tmp_element = root_;
  34. do {
  35. if(tmp_element->key() < tmp_element.left().key()) {
  36. tmp_element = tmp_element->left();
  37. } else {
  38. tmp_element = tmp_element->right();
  39. }
  40. } while(tmp_element.is_not_leaf());
  41.  
  42. if(tmp_element->key() == key) {
  43. return tmp_element->data();
  44. } else {
  45. throw not_found_exception(key);
  46. }
  47. }
  48.  
  49. } // end tree namespace
  50.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:21:9: warning: #pragma once in main file [enabled by default]
 #pragma once
         ^
prog.cpp:23:30: fatal error: ../tree_binary.hpp: No such file or directory
 #include "../tree_binary.hpp"
                              ^
compilation terminated.
stdout
Standard output is empty