From 6ba9de491c7f0df65f0ed4c0e0e3fdebc57412be Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Wed, 14 Jan 2015 09:09:06 +0100 Subject: Added boolean return values to cVector's InsertUnique(), AppendUnique() and RemoveElement() --- tools.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tools.h b/tools.h index 0a9ecbd4..920a1d11 100644 --- a/tools.h +++ b/tools.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.h 3.5 2015/01/12 12:13:33 kls Exp $ + * $Id: tools.h 3.6 2015/01/14 09:09:06 kls Exp $ */ #ifndef __TOOLS_H @@ -557,10 +557,13 @@ public: else Append(Data); } - void InsertUnique(T Data, int Before = 0) + bool InsertUnique(T Data, int Before = 0) { - if (IndexOf(Data) < 0) + if (IndexOf(Data) < 0) { Insert(Data, Before); + return true; + } + return false; } virtual void Append(T Data) { @@ -568,10 +571,13 @@ public: Realloc(allocated * 3 / 2); // increase size by 50% data[size++] = Data; } - void AppendUnique(T Data) + bool AppendUnique(T Data) { - if (IndexOf(Data) < 0) + if (IndexOf(Data) < 0) { Append(Data); + return true; + } + return false; } virtual void Remove(int Index) { @@ -581,11 +587,14 @@ public: memmove(&data[Index], &data[Index + 1], (size - Index) * sizeof(T)); size--; } - void RemoveElement(const T &Data) + bool RemoveElement(const T &Data) { int i = IndexOf(Data); - if (i >= 0) + if (i >= 0) { Remove(i); + return true; + } + return false; } virtual void Clear(void) { -- cgit v1.2.3