This file is indexed.

/usr/include/CiftiLib/Common/MultiDimArray.h is in libcifti-dev 1.5.1-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef __MULTI_DIM_ARRAY_H__
#define __MULTI_DIM_ARRAY_H__

/*LICENSE_START*/ 
/*
 *  Copyright (c) 2014, Washington University School of Medicine
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without modification,
 *  are permitted provided that the following conditions are met:
 *
 *  1. Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *
 *  2. Redistributions in binary form must reproduce the above copyright notice,
 *  this list of conditions and the following disclaimer in the documentation
 *  and/or other materials provided with the distribution.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "CiftiAssert.h"

#include "stdint.h"
#include <vector>

namespace cifti
{
    
    template<typename T>
    class MultiDimArray
    {
        std::vector<int64_t> m_dims, m_skip;//always use int64_t for indexes internally
        std::vector<T> m_data;
        template<typename I>
        int64_t index(const int& fullDims, const std::vector<I>& indexSelect) const;//assume we never need over 2 billion dimensions
    public:
        const std::vector<int64_t>& getDimensions() const { return m_dims; }
        template<typename I>
        void resize(const std::vector<I>& dims);//destructive resize
        template<typename I>
        T& at(const std::vector<I>& pos);
        template<typename I>
        const T& at(const std::vector<I>& pos) const;
        template<typename I>
        T* get(const int& fullDims, const std::vector<I>& indexSelect);//subarray reference selection
        template<typename I>
        const T* get(const int& fullDims, const std::vector<I>& indexSelect) const;
    };
    
    template<typename T>
    template<typename I>
    void MultiDimArray<T>::resize(const std::vector<I>& dims)
    {
        m_dims = std::vector<int64_t>(dims.begin(), dims.end());
        m_skip.resize(m_dims.size());
        if (dims.size() == 0)
        {
            m_data.clear();
            return;
        }
        int64_t numElems = 1;
        for (int i = 0; i < (int)m_dims.size(); ++i)
        {
            CiftiAssert(m_dims[i] > 0);
            m_skip[i] = numElems;
            numElems *= m_dims[i];
        }
        m_data.resize(numElems);
    }
    
    template<typename T>
    template<typename I>
    int64_t MultiDimArray<T>::index(const int& fullDims, const std::vector<I>& indexSelect) const
    {
        CiftiAssert(fullDims + indexSelect.size() == m_dims.size());
        int64_t ret = 0;
        for (int i = fullDims; i < (int)m_dims.size(); ++i)
        {
            CiftiAssert(indexSelect[i - fullDims] >= 0 && indexSelect[i - fullDims] < m_dims[i]);
            ret += m_skip[i] * indexSelect[i - fullDims];
        }
        return ret;
    }
    
    template<typename T>
    template<typename I>
    T& MultiDimArray<T>::at(const std::vector<I>& pos)
    {
        return m_data[index(0, pos)];
    }
    
    template<typename T>
    template<typename I>
    const T& MultiDimArray<T>::at(const std::vector<I>& pos) const
    {
        return m_data[index(0, pos)];
    }
    
    template<typename T>
    template<typename I>
    T* MultiDimArray<T>::get(const int& fullDims, const std::vector<I>& indexSelect)
    {
        return m_data.data() + index(fullDims, indexSelect);
    }
    
    template<typename T>
    template<typename I>
    const T* MultiDimArray<T>::get(const int& fullDims, const std::vector<I>& indexSelect) const
    {
        return m_data.data() + index(fullDims, indexSelect);
    }
}

#endif //__MULTI_DIM_ARRAY_H__