Author: thebeing
Date: Thu Jul 16 09:38:14 2015
New Revision: 38802

URL: http://svn.gna.org/viewcvs/gnustep?rev=38802&view=rev
Log:
Implement +addObjectsFromArray: on NSHashTable

Added:
    libs/base/trunk/Headers/GNUstepBase/NSHashTable+GNUstepBase.h
    libs/base/trunk/Source/Additions/NSHashTable+GNUstepBase.m
    libs/base/trunk/Tests/base/NSHashTable/additions.m
Modified:
    libs/base/trunk/ChangeLog
    libs/base/trunk/Source/Additions/GNUmakefile
    libs/base/trunk/Source/GNUmakefile

Modified: libs/base/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=38802&r1=38801&r2=38802&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog   (original)
+++ libs/base/trunk/ChangeLog   Thu Jul 16 09:38:14 2015
@@ -1,3 +1,12 @@
+2015-07-16 Niels Grewe <[email protected]>
+
+       * Headers/GNUstepBase/NSHashTable+GNUstepBase.h
+       * Source/Additions/GNUmakefile
+       * Source/Additions/NSHashTable+GNUstepBase.m
+       * Source/GNUmakefile
+       * Tests/base/NSHashTable/additions.m:
+       Implement -addObjectsFromArray: on NSHashTable.
+
 2015-07-15  Richard Frith-Macdonald <[email protected]>
 
        * Headers/GNUstepBase/GSIMap.h:

Added: libs/base/trunk/Headers/GNUstepBase/NSHashTable+GNUstepBase.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Headers/GNUstepBase/NSHashTable%2BGNUstepBase.h?rev=38802&view=auto
==============================================================================
--- libs/base/trunk/Headers/GNUstepBase/NSHashTable+GNUstepBase.h       (added)
+++ libs/base/trunk/Headers/GNUstepBase/NSHashTable+GNUstepBase.h       Thu Jul 
16 09:38:14 2015
@@ -0,0 +1,53 @@
+/** Declaration of extension methods for base additions
+
+   Copyright (C) 2015 Free Software Foundation, Inc.
+
+   Written by:  Niels Grewe <[email protected]>
+
+   This file is part of the GNUstep Base Library.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02111 USA.
+
+*/
+
+#ifndef        INCLUDED_NSHashTable_GNUstepBase_h
+#define        INCLUDED_NSHashTable_GNUstepBase_h
+
+#import <GNUstepBase/GSVersionMacros.h>
+#import <Foundation/NSHashTable.h>
+
+#if    defined(__cplusplus)
+extern "C" {
+#endif
+
+#if    OS_API_VERSION(GS_API_NONE,GS_API_LATEST)
+
+@interface NSHashTable (GNUstepBase)
+  /**
+   * Adds each object contained in the given array that is not already
+   * in the hash table.
+   */
+- (void)addObjectsFromArray: (NSArray*)array;
+@end
+
+#endif /* OS_API_VERSION */
+
+#if    defined(__cplusplus)
+}
+#endif
+
+#endif /* INCLUDED_NSHashTable_GNUstepBase_h */
+

Modified: libs/base/trunk/Source/Additions/GNUmakefile
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/Additions/GNUmakefile?rev=38802&r1=38801&r2=38802&view=diff
==============================================================================
--- libs/base/trunk/Source/Additions/GNUmakefile        (original)
+++ libs/base/trunk/Source/Additions/GNUmakefile        Thu Jul 16 09:38:14 2015
@@ -51,6 +51,7 @@
        NSData+GNUstepBase.m \
        NSDebug+GNUstepBase.m \
        NSError+GNUstepBase.m \
+       NSHashTable+GNUstepBase.m \
        NSFileHandle+GNUstepBase.m \
        NSLock+GNUstepBase.m \
        NSMutableString+GNUstepBase.m \

Added: libs/base/trunk/Source/Additions/NSHashTable+GNUstepBase.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/Additions/NSHashTable%2BGNUstepBase.m?rev=38802&view=auto
==============================================================================
--- libs/base/trunk/Source/Additions/NSHashTable+GNUstepBase.m  (added)
+++ libs/base/trunk/Source/Additions/NSHashTable+GNUstepBase.m  Thu Jul 16 
09:38:14 2015
@@ -0,0 +1,39 @@
+/* Implementation of extension methods to base additions
+
+   Copyright (C) 2015 Free Software Foundation, Inc.
+
+   Written by:  Niels Grewe <[email protected]>
+
+   This file is part of the GNUstep Base Library.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02111 USA.
+
+*/
+#import "common.h"
+#import "Foundation/NSArray.h"
+#import "GNUstepBase/NSHashTable+GNUstepBase.h"
+#import "GSPrivate.h"
+#import "GSFastEnumeration.h"
+
+@implementation NSHashTable (GNUstepBase)
+
+- (void)addObjectsFromArray: (NSArray*)array
+{
+  FOR_IN(id, obj, array)
+    NSHashInsert(self,obj);
+  END_FOR_IN(array)
+}
+@end

Modified: libs/base/trunk/Source/GNUmakefile
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/GNUmakefile?rev=38802&r1=38801&r2=38802&view=diff
==============================================================================
--- libs/base/trunk/Source/GNUmakefile  (original)
+++ libs/base/trunk/Source/GNUmakefile  Thu Jul 16 09:38:14 2015
@@ -132,6 +132,7 @@
 NSData+GNUstepBase.h \
 NSDebug+GNUstepBase.h \
 NSFileHandle+GNUstepBase.h \
+NSHashTable+GNUstepBase.h
 NSLock+GNUstepBase.h \
 NSMutableString+GNUstepBase.h \
 NSNetServices+GNUstepBase.h \

Added: libs/base/trunk/Tests/base/NSHashTable/additions.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Tests/base/NSHashTable/additions.m?rev=38802&view=auto
==============================================================================
--- libs/base/trunk/Tests/base/NSHashTable/additions.m  (added)
+++ libs/base/trunk/Tests/base/NSHashTable/additions.m  Thu Jul 16 09:38:14 2015
@@ -0,0 +1,21 @@
+#import "ObjectTesting.h"
+#import <GNUstepBase/NSHashTable+GNUstepBase.h> 
+#import <Foundation/NSArray.h>
+#import <Foundation/NSAutoreleasePool.h>
+
+
+int main()
+{
+  NSAutoreleasePool   *arp = [NSAutoreleasePool new];
+  NSHashTable *obj = [[NSHashTable new] autorelease];
+  NSString *strA = @"a";
+  NSString *strB = @"b";
+  NSArray *a = [NSArray arrayWithObjects: strA, strB, strA, nil];
+  [obj addObjectsFromArray: a];
+  PASS([obj count] == 2, "-addObjectsFromArray: adds objects ignoring 
duplicates");
+  PASS([obj containsObject: strA] && [obj containsObject: strB], "Table 
contains correct objects");
+
+  [arp release]; arp = nil;
+  return 0;
+} 
+


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to