Latest 0.2.1
Homepage https://github.com/Dzamir/DZAUnsafeMutableArray
License MIT
Platforms ios 8.0, osx 10.10, watchos 2.0, tvos 9.0
Authors

What is this for

This class is an Objective-C wrapper around a c auto-growing pointer array.

I built this library because I’m rewriting RouletteBetter and I wanted a way to make lot of statistics calculation on vectors. To do so, we can use the iOS Accelerate framework to ‘Make large-scale mathematical computations and image calculations, optimized for high performance’. Unfortunately the Accelerate framework wants basic c pointer array as input/output parameters, so we can’t use NSMutableArray or high level NSObjects.

With this wrapper library, we can easily create and manupulate the c pointer array as an high level object and, whenewer we need it, access the low level pointer property (for example to pass it to the Accelerate framework c functions).

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Example usage:

    // create and fill the array as an high level object
    DZAUnsafeMutableArray * unsafeArray = [[DZAUnsafeMutableArray alloc] initWithCapacity:10];
    for (int i = 0; i < 10; i++)
    {
        [unsafeArray addInt:i];
    }

    // access an element of the array
    int element = [unsafeArray intAtIndex:3];
    // remove the last object
    [unsafeArray removeLastObject];
    // shrink the array to the new size
    [unsafeArray shrinkToSize:5];
    // low-level access to the c pointer array
    int * pointer = unsafeArray.intUnsafePointer;
    // iterate all the items and manually sum a scalar
    for (int i = 0; i < unsafeArray1.count; i++, pointer++)
    {
        *pointer += SCALAR;
    }
    // use the c pointer array with Accelerate framework:
    // sums a scalar to the entire vector
    int scalar = 3;
    vDSP_vsaddi(unsafeArray.intUnsafePointer, 1, &scalar, unsafeArray.intUnsafePointer, 1, unsafeArray.count);

A small benchmark app is included:

Benchmark with small array
Benchmark with big array

Requirements

Installation

DZAUnsafeMutableArray is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "DZAUnsafeMutableArray"

Author

Davide Di Stefano, [email protected]

License

DZAUnsafeMutableArray is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "DZAUnsafeMutableArray",
    "version": "0.2.1",
    "summary": "An Objective-C wrapper around a c auto-growing pointer array.",
    "description": "I built this library because I'm rewriting [RouletteBetter](https://itunes.apple.com/us/app/roulettebetter-odds-calculator-betting-strategies-for/id310598685?mt=8) and I wanted a way to make *lot* of statistics calculation on vectors. To do so, we can use the [iOS Accelerate framework](https://developer.apple.com/documentation/accelerate) to 'Make large-scale mathematical computations and image calculations, optimized for high performance'. Unfortunately the Accelerate framework wants basic c pointer array as input/output parameters, so we can't use NSMutableArray or high level NSObjects.nnWith this wrapper library, we can easily create and manupulate the c pointer array as an high level object and, whenewer we need it, access the low level pointer property (for example to pass it to the Accelerate framework c functions).",
    "homepage": "https://github.com/Dzamir/DZAUnsafeMutableArray",
    "screenshots": [
        "https://raw.githubusercontent.com/Dzamir/DZAUnsafeMutableArray/master/screen_2.jpg",
        "https://raw.githubusercontent.com/Dzamir/DZAUnsafeMutableArray/master/screen_1.jpg"
    ],
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Davide Di Stefano": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Dzamir/DZAUnsafeMutableArray.git",
        "tag": "0.2.1"
    },
    "social_media_url": "https://twitter.com/dzamir",
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source_files": "DZAUnsafeMutableArray/Classes/**/*"
}

Pin It on Pinterest

Share This