~ubuntu-branches/ubuntu/utopic/gnustep-base/utopic

« back to all changes in this revision

Viewing changes to Source/GSSet.m

  • Committer: Package Import Robot
  • Author(s): Paul Gevers
  • Date: 2014-07-19 13:02:18 UTC
  • mfrom: (20.1.6 utopic-proposed)
  • Revision ID: package-import@ubuntu.com-20140719130218-pn967l7wzjjf90yi
Tags: 1.24.6-2ubuntu1
* debian/rules:
  - Print the config.log if configure fails to debug
    powerpc/ppc64el FTBFS. (LP: #1277975)

Show diffs side-by-side

added added

removed removed

Lines of Context:
280
280
{
281
281
  Class c;
282
282
 
283
 
  /*
284
 
   *  If this set is empty, or the other is nil, this method should return NO.
 
283
  /* If this set is empty, or the other is nil/empty,
 
284
   * this method should return NO.
285
285
   */
286
 
  if (map.nodeCount == 0)
287
 
    {
288
 
      return NO;
289
 
    }
290
 
  if (otherSet == nil)
 
286
  if (0 == map.nodeCount || nil == otherSet || [otherSet count] == 0)
291
287
    {
292
288
      return NO;
293
289
    }
632
628
  return self;
633
629
}
634
630
 
635
 
- (void) intersectSet: (NSSet*) other
 
631
- (void) intersectSet: (NSSet*)other
636
632
{
637
 
  if (other != self)
638
 
    {
639
 
      GSIMapEnumerator_t        enumerator = GSIMapEnumeratorForMap(&map);
640
 
      GSIMapBucket              bucket = GSIMapEnumeratorBucket(&enumerator);
641
 
      GSIMapNode                node = GSIMapEnumeratorNextNode(&enumerator);
642
 
 
643
 
      while (node != 0)
644
 
        {
645
 
 
646
 
          if ([other containsObject: node->key.obj] == NO)
647
 
            {
648
 
              GSIMapRemoveNodeFromMap(&map, bucket, node);
649
 
              GSIMapFreeNode(&map, node);
650
 
            }
651
 
          bucket = GSIMapEnumeratorBucket(&enumerator);
652
 
          node = GSIMapEnumeratorNextNode(&enumerator);
653
 
        }
654
 
      GSIMapEndEnumerator(&enumerator);
 
633
  if (nil == other)
 
634
    {
 
635
      GSIMapCleanMap(&map);
 
636
    }
 
637
  else if (other != self && map.nodeCount > 0)
 
638
    {
 
639
      GSIMapEnumerator_t        enumerator;
 
640
      GSIMapBucket              bucket;
 
641
      GSIMapNode                node;
 
642
      Class                     c;
 
643
 
 
644
      if (NO == [other isKindOfClass: [NSSet class]])
 
645
        {
 
646
          [NSException raise: NSInvalidArgumentException
 
647
                      format: @"-intersectSet: other object is not a set"];
 
648
        }
 
649
      if (0 == map.nodeCount)
 
650
        {
 
651
          return;                       // Already empty ... nothing to do
 
652
        }
 
653
      if (0 == [other count])
 
654
        {
 
655
          GSIMapCleanMap(&map);         // Other empty ... no intersection
 
656
          return;
 
657
        }
 
658
 
 
659
      c = object_getClass(other);
 
660
      if (c == setClass || c == mutableSetClass)
 
661
        {
 
662
          GSSet *o = (GSSet*)other;
 
663
 
 
664
          enumerator = GSIMapEnumeratorForMap(&map);
 
665
          bucket = GSIMapEnumeratorBucket(&enumerator);
 
666
          node = GSIMapEnumeratorNextNode(&enumerator);
 
667
 
 
668
          while (node != 0)
 
669
            {
 
670
              if (0 == GSIMapNodeForKey(&o->map, node->key))
 
671
                {
 
672
                  GSIMapRemoveNodeFromMap(&map, bucket, node);
 
673
                  GSIMapFreeNode(&map, node);
 
674
                }
 
675
              bucket = GSIMapEnumeratorBucket(&enumerator);
 
676
              node = GSIMapEnumeratorNextNode(&enumerator);
 
677
            }
 
678
          GSIMapEndEnumerator(&enumerator);
 
679
        }
 
680
      else
 
681
        {
 
682
          SEL   sel = @selector(member:);
 
683
          IMP   imp = [other methodForSelector: sel];
 
684
 
 
685
          enumerator = GSIMapEnumeratorForMap(&map);
 
686
          bucket = GSIMapEnumeratorBucket(&enumerator);
 
687
          node = GSIMapEnumeratorNextNode(&enumerator);
 
688
 
 
689
          while (node != 0)
 
690
            {
 
691
              if (nil == (*imp)(other, sel, node->key.obj))
 
692
                {
 
693
                  GSIMapRemoveNodeFromMap(&map, bucket, node);
 
694
                  GSIMapFreeNode(&map, node);
 
695
                }
 
696
              bucket = GSIMapEnumeratorBucket(&enumerator);
 
697
              node = GSIMapEnumeratorNextNode(&enumerator);
 
698
            }
 
699
          GSIMapEndEnumerator(&enumerator);
 
700
        }
655
701
    }
656
702
}
657
703