Subversion Repositories gelsvn

Rev

Rev 520 | Rev 526 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 520 Rev 522
Line 23... Line 23...
23
    {
23
    {
24
    public:
24
    public:
25
        /// Construct from optional size and item (size should be identical to number of entities in associated container
25
        /// Construct from optional size and item (size should be identical to number of entities in associated container
26
        AttributeVector(size_t _size = 0, ITEM item = ITEM());
26
        AttributeVector(size_t _size = 0, ITEM item = ITEM());
27
 
27
 
28
        /// Add an item (possibly not necessary
28
        /// Add an item
29
       // ITEMID add(const ITEM& item);
29
       // ITEMID add(const ITEM& item);
30
 
30
 
31
        /// const reference to item given by ID
31
        /// const reference to item given by ID
32
        const ITEM& get(ITEMID id) const;
32
        const ITEM& get(ITEMID id) const;
33
 
33
 
Line 38... Line 38...
38
        const ITEM& operator [](ITEMID id) const;
38
        const ITEM& operator [](ITEMID id) const;
39
 
39
 
40
        /// reference to item given by ID
40
        /// reference to item given by ID
41
        ITEM& operator [](ITEMID id);
41
        ITEM& operator [](ITEMID id);
42
 
42
 
43
        /// resize the vector (may be necessary if associated container size grows
43
        /// resize the vector (may be necessary if associated container size grows)
44
        void resize(size_t _size, ITEM item = ITEM());
44
        void resize(size_t _size, ITEM item = ITEM());
45
 
45
 
46
        /// number of attribute items in vector
46
        /// number of attribute items in vector
47
        size_t size() const;
47
        size_t size() const;
48
 
48
 
Line 128... Line 128...
128
    }
128
    }
129
 
129
 
130
    template<typename ITEM, typename ITEMID>
130
    template<typename ITEM, typename ITEMID>
131
    inline ITEM& AttributeVector<ITEM, ITEMID>::get(ITEMID id)
131
    inline ITEM& AttributeVector<ITEM, ITEMID>::get(ITEMID id)
132
    {
132
    {
133
        if(items.size() < id.idx())
133
        if(id.index >= items.size())
134
            items.resize(id.index + 1);
134
            items.resize(id.index + 1);
135
        return items[id.index]; 
135
        return items[id.index]; 
136
    }
136
    }
137
 
137
 
138
    template<typename ITEM, typename ITEMID>
138
    template<typename ITEM, typename ITEMID>
Line 143... Line 143...
143
    }
143
    }
144
 
144
 
145
    template<typename ITEM, typename ITEMID>
145
    template<typename ITEM, typename ITEMID>
146
    inline ITEM& AttributeVector<ITEM, ITEMID>::operator [](ITEMID id)
146
    inline ITEM& AttributeVector<ITEM, ITEMID>::operator [](ITEMID id)
147
    {
147
    {
148
        if(items.size() < id.index)
148
        if(id.index >= items.size())
149
            items.resize(id.index + 1);
149
            items.resize(id.index + 1);
150
        return items[id.index]; 
150
        return items[id.index]; 
151
    }
151
    }
152
}
152
}
153
 
153