コード例 #1
0
void Prefs_KeyboardShortcuts::restoreDefaults(struct ApplicationPrefs *prefsData)
{
	keyMap=prefsData->keyShortcutPrefs.KeyActions;
	loadableSets->clear();
	loadableSets->addItems(scanForSets());
	insertActions();
	dispKey(0);
}
コード例 #2
0
ファイル: perfhlib.c プロジェクト: Nico01/dcc
bool DFS(int parentE, int v)
{
    int e, w;

    /* Depth first search of the graph, starting at vertex v, looking for cycles.
       parent and v are origin 1. Note parent is an EDGE, not a vertex */

    visited[v] = true;

    // For each e incident with v ..
    for (e = graphFirst[v]; e; e = graphNext[NumEntry + e]) {
        uint8_t *key1;

        getKey(abs(e) - 1, &key1);

        if (*(long *)key1 == 0) // A deleted key. Just ignore it
            continue;

        w = graphNode[NumEntry + e];
        if (visited[w]) {
            // Did we just come through this edge? If so, ignore it.
            if (abs(e) != abs(parentE)) {
                /* There is a cycle in the graph. There is some subtle code here
                   to work around the distinct possibility that there may be
                   duplicate keys. Duplicate keys will always cause unit
                   cycles, since f1 and f2 (used to select v and w) will be the
                   same for both. The edges (representing an index into the
                   array of keys) are distinct, but the key values are not.
                   The logic is as follows: for the candidate edge e, check to
                   see if it terminates in the parent vertex. If so, we test
                   the keys associated with e and the parent, and if they are
                   the same, we can safely ignore e for the purposes of cycle
                   detection, since edge e adds nothing to the cycle. Cycles
                   involving v, w, and e0 will still be found. The parent
                   edge was not similarly eliminated because at the time when
                   it was a candidate, v was not yet visited.
                   We still have to remove the key from further consideration,
                   since each edge is visited twice, but with a different
                   parent edge each time.
                */
                /* We save some stack space by calculating the parent vertex
                   for these relatively few cases where it is needed */
                int parentV = graphNode[NumEntry - parentE];

                if (w == parentV) {
                    uint8_t *key2;

                    getKey(abs(parentE) - 1, &key2);

                    if (memcmp(key1, key2, EntryLen) == 0) {
                        printf("Duplicate keys with edges %d and %d (", e, parentE);
                        dispKey(abs(e) - 1);
                        printf(" & ");
                        dispKey(abs(parentE) - 1);
                        printf(")\n");
                        memset(key1, 0, EntryLen);
                    } else { // A genuine (unit) cycle.
                        printf("There is a unit cycle involving vertex %d and edge %d\n", v, e);
                        return true;
                    }

                } else {
                    /* We have reached a previously visited vertex not the
                       parent. Therefore, we have uncovered a genuine cycle */
                    printf("There is a cycle involving vertex %d and edge %d\n", v, e);
                    return true;
                }
            }
        }
        else { // Not yet seen. Traverse it
            if (DFS(e, w)) // Cycle found deeper down. Exit
                return true;
        }
    }
    return false;
}