Added isParentOf() function.
This commit is contained in:
parent
bf3b1d9dc9
commit
8eacc34869
@ -192,6 +192,20 @@ const bool path::isDirectParentOf(const path& p) const
|
||||
}
|
||||
|
||||
|
||||
const bool path::isParentOf(const path& p) const
|
||||
{
|
||||
if (p.getSize() < getSize() + 1)
|
||||
return (false);
|
||||
|
||||
bool equal = true;
|
||||
|
||||
for (list::size_type i = 0 ; equal && i < m_list.size() ; ++i)
|
||||
equal = (m_list[i] == p.m_list[i]);
|
||||
|
||||
return (equal);
|
||||
}
|
||||
|
||||
|
||||
void path::appendComponent(const path::component& c)
|
||||
{
|
||||
m_list.push_back(c);
|
||||
|
@ -124,12 +124,20 @@ public:
|
||||
component& operator[](const int x);
|
||||
|
||||
/** Test whether this path is a direct parent of another one.
|
||||
*
|
||||
* @param p other path
|
||||
* @return true if the specified path is a child
|
||||
* of this path, false otherwise
|
||||
*/
|
||||
const bool isDirectParentOf(const path& p) const;
|
||||
|
||||
/** Test whether this path is a parent of another one.
|
||||
*
|
||||
* @param p other path
|
||||
* @return true if the specified path is a child (direct or
|
||||
* indirect) of this path, false otherwise
|
||||
*/
|
||||
const bool isDirectParentOf(const path& p) const;
|
||||
const bool isParentOf(const path& p) const;
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user