COIN-OR::LEMON - Graph Library

Opened 10 years ago

Closed 10 years ago

#353 closed defect (fixed)

Clarify typenames in NetworkSimplex

Reported by: Peter Kovacs Owned by: Peter Kovacs
Priority: major Milestone: LEMON 1.2 release
Component: core Version: hg main
Keywords: Cc:
Revision id:

Description

In [f3bc4e9b5f3a], the following typedefs

  typedef std::vector<char> CharVector;

was replaced with

  typedef std::vector<char> BoolVector;
  // Note: vector<char> is used instead of vector<bool> for efficiency reasons

in all min cost flow classes to indicate that these types are used to store boolean values and char is only used for efficiency reasons. But in NetworkSimplex, it is not true. There are two vectors: the first one stores boolean values, but the other one stores {-1, 0, 1} values. Using the name BoolVector for the latter case is misleading. So I was not careful enough when I made those renamings, but the attached patch separates these two use cases.

Attachments (2)

353-195511e0b806.patch (2.2 KB) - added by Peter Kovacs 10 years ago.
353-b6f76c95992e.patch (2.4 KB) - added by Peter Kovacs 10 years ago.

Download all attachments as: .zip

Change History (7)

Changed 10 years ago by Peter Kovacs

Attachment: 353-195511e0b806.patch added

comment:1 Changed 10 years ago by Peter Kovacs

Status: newassigned

[195511e0b806] is attached.

comment:2 Changed 10 years ago by Alpar Juttner

Is char a signed type? Don't you want to use signed char instead?

Also, I prefer referring to the type of the data instead the binary representation, i.e. StateVector instead of CharVector. For example this problem would not occur if we followed this rule.

comment:3 in reply to:  2 Changed 10 years ago by Peter Kovacs

Replying to alpar:

Is char a signed type? Don't you want to use signed char instead?

Hmm. I thought that char is always the same as signed char just like int is signed int. But I found that: "It is up to the compiler to decide whether "plain" char or default char is signed or unsigned". So, we should use signed char here. Thank you for the observation.

Also, I prefer referring to the type of the data instead the binary representation, i.e. StateVector instead of CharVector. For example this problem would not occur if we followed this rule.

That was my first idea here, but all the other XyzVector typedefs refer to the item type. E.g. IntVector is used for representing many different "maps" (both for nodes and arcs).

Another possibility is to use vector<ArcSateEnum>, where ArcSateEnum is an enum type with three different values. But it is stored as a vector<int>, so I prefer vector<signed char>.

Changed 10 years ago by Peter Kovacs

Attachment: 353-b6f76c95992e.patch added

comment:4 Changed 10 years ago by Peter Kovacs

See the new patch [b6f76c95992e].

comment:5 Changed 10 years ago by Alpar Juttner

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.