COIN-OR::LEMON - Graph Library

Opened 11 years ago

Last modified 8 years ago

#466 new enhancement

Extended std::vector<>

Reported by: Alpar Juttner Owned by: Alpar Juttner
Priority: major Milestone: LEMON 1.5 release
Component: core Version: hg main
Keywords: Cc:
Revision id:

Description

Based upon the idea of #462.

We could implement a wrapper around std::vector<> with the following two extra features.

  • A extra permanent iterator. It has the same functionality as std::vector::iterator but remains valid even when the vector is extended by new elements. Technically, it contains a pointer to the base vector plus an index.
  • An index type. In non-debug mode it is just a size_t, but in debug mode it also contains a pointer to the vector it indexes, thus operator[]() is able to check if the index indexes the right vector (and also if it is in the actual range).

Both would be safer alternatives to referencing std::vector<>'s elements by integer indices.

Attachments (1)

466.diff (16.2 KB) - added by Andras Kucsma 10 years ago.
Implementation of safe_vector

Download all attachments as: .zip

Change History (3)

comment:1 Changed 11 years ago by Alpar Juttner

The point is that I'm just debugging a code which uses many std::vector<>s and (integer) cross references between them and does something wrong. If we used one of the features above for cross referencing, it would immediately locate the root of the problem.

Changed 10 years ago by Andras Kucsma

Attachment: 466.diff added

Implementation of safe_vector

comment:2 Changed 8 years ago by Alpar Juttner

Milestone: LEMON 1.4 releaseLEMON 1.5 release
Note: See TracTickets for help on using tickets.