| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2006-2015 Dmitry Tsarkov and The University of Manchester |
| 3 | Copyright (C) 2015-2017 Dmitry Tsarkov |
| 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 | #ifndef DLVHASHIMPL_H |
| 21 | #define DLVHASHIMPL_H |
| 22 | |
| 23 | // implementation of DLVertex Hash; to be included after DLDag definition |
| 24 | |
| 25 | inline BipolarPointer |
| 26 | dlVHashTable :: locate ( const HashLeaf& leaf, const DLVertex& v ) const |
| 27 | { |
| 28 | for ( const auto& bp: leaf ) |
| 29 | if ( v == host[bp] ) |
| 30 | return bp; |
| 31 | |
| 32 | return bpINVALID; |
| 33 | } |
| 34 | |
| 35 | inline BipolarPointer |
| 36 | dlVHashTable :: locate ( const DLVertex& v ) const |
| 37 | { |
| 38 | auto p = Table.find(hash(v)); |
| 39 | return p == Table.end() ? bpINVALID : locate ( p->second, v ); |
| 40 | } |
| 41 | |
| 42 | inline void |
| 43 | dlVHashTable :: addElement ( BipolarPointer pos ) |
| 44 | { |
| 45 | insert ( Table[hash(host[pos])], pos ); |
| 46 | } |
| 47 | |
| 48 | #endif |
| 49 |