Opened 15 years ago
Closed 15 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)
Change History (7)
Changed 15 years ago by
Attachment: | 353-195511e0b806.patch added |
---|
comment:1 Changed 15 years ago by
Status: | new → assigned |
---|
comment:2 follow-up: 3 Changed 15 years ago by
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 Changed 15 years ago by
Replying to alpar:
Is
char
a signed type? Don't you want to usesigned 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 ofCharVector
. 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 15 years ago by
Attachment: | 353-b6f76c95992e.patch added |
---|
comment:5 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
[195511e0b806] is attached.