Skip to content

An API for letting the c_ function to leave information for its u_ function if it's called immediately after. #617

@krivit

Description

@krivit

Recall the sqrt(triangles) example. The c_ function must compute the change statistic for the number of triangles due to the proposed toggle. If this toggle is then accepted, the u_ function must repeat this calculation to update the stored number of triangles. This is both code duplication and waste of computing time.

A simple API change would be to create a new container element on the ModelTerm struct, e.g.,

struct {
  Vertex i, j;
  void *payload;
}

that the c_ function is allowed to write to, recording the toggle information and whatever data structure the c_ function wants to pass along.

Then the u_ function must check that it's the same toggle, use the information, then set i and j to 0 so that on the off chance that it is called again without a c_ call in between, it'll know that the information is not valid.

The f_ function, as in case of the other storage, can free the payload if not NULL and then free the struct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions