Sha256: cd598d27d8390e4cef639c9daa5c5b7d6eafbb93164ae041371e390853ce7ec4

Contents?: true

Size: 937 Bytes

Versions: 13

Compression:

Stored size: 937 Bytes

Contents

// Copyright (C) 2013  Davis E. King (davis@dlib.net)
// License: Boost Software License   See LICENSE.txt for the full license.
#ifndef DLIB_ARRAY_tOOLS_H_
#define DLIB_ARRAY_tOOLS_H_

#include "../assert.h"
#include "array_tools_abstract.h"

namespace dlib
{
    template <typename T>
    void split_array (
        T& a,
        T& b,
        double frac
    )
    {
        // make sure requires clause is not broken
        DLIB_ASSERT(0 <= frac && frac <= 1,
            "\t void split_array()"
            << "\n\t frac must be between 0 and 1."
            << "\n\t frac: " << frac
            );

        const unsigned long asize = static_cast<unsigned long>(a.size()*frac);
        const unsigned long bsize = a.size()-asize;

        b.resize(bsize);
        for (unsigned long i = 0; i < b.size(); ++i)
        {
            swap(b[i], a[i+asize]);
        }
        a.resize(asize);
    }
}

#endif // DLIB_ARRAY_tOOLS_H_

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dlib-1.2.2 ext/dlib-19.4/dlib/array/array_tools.h
dlib-1.2.1 ext/dlib-19.4/dlib/array/array_tools.h
dlib-1.2.0 ext/dlib-19.4/dlib/array/array_tools.h
dlib-1.1.5 ext/dlib-19.4/dlib/array/array_tools.h
dlib-1.1.4 ext/dlib-19.4/dlib/array/array_tools.h
dlib-1.1.3 ext/dlib-19.4/dlib/array/array_tools.h
dlib-1.1.2 ext/dlib-19.4/dlib/array/array_tools.h
dlib-1.1.1 ext/dlib-19.4/dlib/array/array_tools.h
dlib-1.1.0 ext/dlib-19.4/dlib/array/array_tools.h
dlib-1.0.3 ext/dlib-18.13/dlib/array/array_tools.h
dlib-1.0.2 ext/dlib-18.13/dlib/array/array_tools.h
dlib-1.0.1 ext/dlib-18.13/dlib/array/array_tools.h
dlib-1.0.0 ext/dlib-18.13/dlib/array/array_tools.h