next up previous contents
Next: 5 Querying Existing Relations Up: 4 Building New Relations Previous: 4.4 Building atomic constraints

4.5 Finalization

Many of our data structures can be finalized when they are complete. This is done via the various finalize() member functions. Adding new constraints to a structure that has been finalized is illegal. Explicit finalization allows the implementation to perform certain simplifications of constraints, which can improve efficiency in some cases. For example, we could provide an optimization that simply discards any constraints that are added to an F_Or that contains a tautology (this optimization is not currently in the library, but it is easy to explain). We can only be sure that one of the children is a tautology after it has been finalized: otherwise we would have to consider the possibility of the programmer adding something like to this child, in which case it is no longer a tautology. Since finalization does not affect the relation, we have not shown its use in our examples. However, finalization is important to achieving maximum efficiency. If you are concerned with efficiency, you should finalize each part of a relation as soon as you have finished building it.