lean2/src/util/name_set.cpp
Leonardo de Moura 7ff791eb9f feat(util/name_set): add mk_unique (with respect to a name_set)
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-30 11:28:38 -08:00

20 lines
443 B
C++

/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include "util/name_set.h"
namespace lean {
name mk_unique(name_set const & s, name const & suggestion) {
name n = suggestion;
int i = 1;
while (true) {
if (s.find(n) == s.end())
return n;
n = name(suggestion, i);
i++;
}
}
}