delegation-list: add DelegationList::empty()
Also, add 'noexcept' where applicable.
refs #4055
Change-Id: I3e0ae671541a6bb55079bf13990ba5ca15f312a5
diff --git a/src/delegation-list.hpp b/src/delegation-list.hpp
index 9ef5d97..2a367ba 100644
--- a/src/delegation-list.hpp
+++ b/src/delegation-list.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -81,7 +81,7 @@
wireDecode(const Block& block, bool wantSort = true);
bool
- isSorted() const
+ isSorted() const noexcept
{
return m_isSorted;
}
@@ -89,19 +89,25 @@
using const_iterator = std::vector<Delegation>::const_iterator;
const_iterator
- begin() const
+ begin() const noexcept
{
return m_dels.begin();
}
const_iterator
- end() const
+ end() const noexcept
{
return m_dels.end();
}
+ bool
+ empty() const noexcept
+ {
+ return m_dels.empty();
+ }
+
size_t
- size() const
+ size() const noexcept
{
return m_dels.size();
}
diff --git a/tests/unit-tests/delegation-list.t.cpp b/tests/unit-tests/delegation-list.t.cpp
index b98c67a..7ae92ed 100644
--- a/tests/unit-tests/delegation-list.t.cpp
+++ b/tests/unit-tests/delegation-list.t.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -170,7 +170,9 @@
BOOST_AUTO_TEST_CASE(InsertSimple)
{
DelegationList dl;
+ BOOST_CHECK_EQUAL(dl.empty(), true);
dl.insert(2, "/A");
+ BOOST_CHECK_EQUAL(dl.empty(), false);
dl.insert(1, "/B");
BOOST_CHECK_EQUAL(dl.size(), 2);