HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014 Regents of the University of California, |
| 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology |
| 9 | * |
| 10 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 11 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 12 | * |
| 13 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 14 | * of the GNU General Public License as published by the Free Software Foundation, |
| 15 | * either version 3 of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 18 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 19 | * PURPOSE. See the GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License along with |
| 22 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 23 | **/ |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 24 | |
| 25 | // Name Tree Entry (i.e., Name Prefix Entry) |
| 26 | |
| 27 | #include "name-tree-entry.hpp" |
| 28 | |
| 29 | namespace nfd { |
| 30 | namespace name_tree { |
| 31 | |
Haowei Yuan | f52dac7 | 2014-03-24 23:35:03 -0500 | [diff] [blame] | 32 | Node::Node() |
| 33 | : m_prev(0) |
| 34 | , m_next(0) |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 35 | { |
| 36 | } |
| 37 | |
| 38 | Node::~Node() |
| 39 | { |
| 40 | // erase the Name Tree Nodes that were created to |
| 41 | // resolve hash collisions |
| 42 | // So before erasing a single node, make sure its m_next == 0 |
| 43 | // See eraseEntryIfEmpty in name-tree.cpp |
| 44 | if (m_next) |
| 45 | delete m_next; |
| 46 | } |
| 47 | |
Junxiao Shi | 9f7455b | 2014-04-07 21:02:16 -0700 | [diff] [blame] | 48 | Entry::Entry(const Name& name) |
| 49 | : m_hash(0) |
| 50 | , m_prefix(name) |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 51 | { |
| 52 | } |
| 53 | |
| 54 | Entry::~Entry() |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | void |
Junxiao Shi | 9f7455b | 2014-04-07 21:02:16 -0700 | [diff] [blame] | 59 | Entry::erasePitEntry(shared_ptr<pit::Entry> pitEntry) |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 60 | { |
Junxiao Shi | 9f7455b | 2014-04-07 21:02:16 -0700 | [diff] [blame] | 61 | BOOST_ASSERT(static_cast<bool>(pitEntry)); |
| 62 | BOOST_ASSERT(pitEntry->m_nameTreeEntry.get() == this); |
| 63 | |
| 64 | std::vector<shared_ptr<pit::Entry> >::iterator it = |
| 65 | std::find(m_pitEntries.begin(), m_pitEntries.end(), pitEntry); |
| 66 | BOOST_ASSERT(it != m_pitEntries.end()); |
| 67 | |
| 68 | *it = m_pitEntries.back(); |
| 69 | m_pitEntries.pop_back(); |
| 70 | pitEntry->m_nameTreeEntry.reset(); |
| 71 | } |
| 72 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 73 | } // namespace name_tree |
| 74 | } // namespace nfd |