| 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 DLVHASH_H |
| 21 | #define DLVHASH_Hcxx . . $ `Kernel/dlVHash.h:21:9`! |
| 22 | |
| 23 | #include <map> |
| 24 | #include <list> |
| 25 | #include "dlVertex.h"cxx . . $ `<file>/Kernel/dlVertex.h`/ |
| 26 | #include "tRole.h"cxx . . $ `<file>/Kernel/tRole.h`/ |
| 27 | |
| 28 | /// naive and simple hash table for DL Vertices |
| 29 | class dlVHashTablecxx . . $ dlVHashTable# |
| 30 | { |
| 31 | protected: // types |
| 32 | /// hashed IDs of the DL vertices |
| 33 | typedef stdcxx . . $ std/::listcxx . . $ std/__cxx11/list#<BipolarPointercxx . . $ BipolarPointer#> HashLeafcxx . . $ dlVHashTable#HashLeaf#; |
| 34 | /// hash table by itself |
| 35 | typedef stdcxx . . $ std/::mapcxx . . $ std/map#<BipolarPointercxx . . $ BipolarPointer#, HashLeafcxx . . $ dlVHashTable#HashLeaf#> HashTablecxx . . $ dlVHashTable#HashTable#; |
| 36 | |
| 37 | protected: // members |
| 38 | /// host DAG that contains actual nodes; |
| 39 | const DLDagcxx . . $ DLDag#& hostcxx . . $ dlVHashTable#host.; |
| 40 | /// HT for nodes |
| 41 | HashTablecxx . . $ dlVHashTable#HashTable# Tablecxx . . $ dlVHashTable#Table.; |
| 42 | |
| 43 | protected: // methods |
| 44 | /// get a (very simple) hash of the vertex |
| 45 | static BipolarPointercxx . . $ BipolarPointer# hashcxx . . $ dlVHashTable#hash(8f47413182285a6b). ( const DLVertexcxx . . $ DLVertex#& v ) |
| 46 | { |
| 47 | BipolarPointercxx . . $ BipolarPointer# sum = 0; |
| 48 | if ( v.getRolecxx . . $ DLVertex#getRole(69f26110a94b259f).() != nullptr ) |
| 49 | sum += v.getRolecxx . . $ DLVertex#getRole(69f26110a94b259f).()->getIdcxx . . $ TNamedEntry#getId(455f465bc33b4cdf).(); |
| 50 | if ( v.getProjRolecxx . . $ DLVertex#getProjRole(69f26110a94b259f).() != nullptr ) |
| 51 | sum += v.getProjRolecxx . . $ DLVertex#getProjRole(69f26110a94b259f).()->getIdcxx . . $ TNamedEntry#getId(455f465bc33b4cdf).(); |
| 52 | sum += v.getCcxx . . $ DLVertex#getC(455f465bc33b4cdf).(); |
| 53 | sum += v.getNumberLEcxx . . $ DLVertex#getNumberLE(ddd8539a2fcdd4ce).(); |
| 54 | for ( const auto& arg: v ) |
| 55 | sum += arg; |
| 56 | return sum; |
| 57 | } |
| 58 | |
| 59 | /// insert new POSition into a given LEAF |
| 60 | static void insertcxx . . $ dlVHashTable#insert(345510c98d6b6c89). ( HashLeafcxx . . $ dlVHashTable#HashLeaf#& leaf, BipolarPointercxx . . $ BipolarPointer# pos ) { leaf.push_backcxx . . $ std/__cxx11/list#push_back(77d9f17553126ecb).(pos); } |
| 61 | /// locate vertex V in a given LEAF |
| 62 | BipolarPointercxx . . $ BipolarPointer# locatecxx . . $ dlVHashTable#locate(e38e8d7d654dccb4). ( const HashLeafcxx . . $ dlVHashTable#HashLeaf#& leaf, const DLVertexcxx . . $ DLVertex#& v ) const; |
| 63 | |
| 64 | public: // interface |
| 65 | /// empty c'tor |
| 66 | explicit dlVHashTablecxx . . $ dlVHashTable#dlVHashTable(dd585ec903520274). ( const DLDagcxx . . $ DLDag#& dag ) : hostcxx . . $ dlVHashTable#host.(dag) {} |
| 67 | |
| 68 | /// add an element (given by a POSition) to hash |
| 69 | void addElementcxx . . $ dlVHashTable#addElement(d4f767463ce0a6b3). ( BipolarPointercxx . . $ BipolarPointer# pos ); |
| 70 | /// locate given vertex in the hash |
| 71 | BipolarPointercxx . . $ BipolarPointer# locatecxx . . $ dlVHashTable#locate(afc6382ab0cd3b8b). ( const DLVertexcxx . . $ DLVertex#& v ) const; |
| 72 | }; // dlVHashTable |
| 73 | |
| 74 | #endif |