Sha256: 907957fc838cf133250ff9f9ed0ba5846f79a19525e26232a7cbb8c853fef256

Contents?: true

Size: 1.24 KB

Versions: 44

Compression:

Stored size: 1.24 KB

Contents

// Copyright (c) 2011 Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "ObjCVectorInternal.h"
#import "ObjCVector.h"

#include <vector>

@interface ObjCVector (Private)
- (std::vector<id>::iterator)makeIterator:(NSUInteger)index;
@end

@implementation ObjCVector

- (id)init {
  if ((self = [super init])) {
    imp_ = new ObjCVectorImp();
  }
  return self;
}

- (void)dealloc {
  delete imp_;
  [super dealloc];
}

- (void)addObject:(id)obj {
  imp_->v.push_back([obj retain]);
}

- (void)addObject:(id)obj atIndex:(NSUInteger)index {
  imp_->v.insert([self makeIterator:index], [obj retain]);
}

- (void)removeObject:(id)obj {
  for (std::vector<id>::iterator it = imp_->v.begin();
       it != imp_->v.end();
       ++it) {
    if ([*it isEqual:obj]) {
      [*it autorelease];
      imp_->v.erase(it);
      return;
    }
  }
}

- (void)removeObjectAtIndex:(NSUInteger)index {
  [imp_->v[index] autorelease];
  imp_->v.erase([self makeIterator:index]);
}

- (id)objectAtIndex:(NSUInteger)index {
  return imp_->v[index];
}

- (std::vector<id>::iterator)makeIterator:(NSUInteger)index {
  std::vector<id>::iterator it = imp_->v.begin();
  it += index;
  return it;
}

@end

Version data entries

44 entries across 44 versions & 7 rubygems

Version Path
libv8-3.16.14.7 vendor/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.16.14.6 vendor/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.16.14.5 vendor/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.16.14.4 vendor/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.16.14.3 vendor/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.16.14.2 vendor/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.16.14.1 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.16.14.0 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.11.8.17 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.11.8.16 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.11.8.13 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.11.8.12 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/libv8-3.11.8.4/vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.11.8.11 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.11.8.10 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.11.8.9 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.11.8.8 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.11.8.7 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-3.11.8.4 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm
libv8-freebsd-3.11.8.3 vendor/v8/build/gyp/test/mac/framework/TestFramework/ObjCVector.mm