本文整理汇总了C#中Set.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Set.ToString方法的具体用法?C# Set.ToString怎么用?C# Set.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRemoveElements
public void AddRemoveElements()
{
var set = new Set<int>(2, 4, 6, 8, 10);
Console.WriteLine(set.ToString());
set.Add(1, 3, 5, 7, 9);
Console.WriteLine(set.ToString());
set.Remove(9);
Console.WriteLine(set.ToString());
}
示例2: AddRemoveElements
public void AddRemoveElements()
{
var set = new Set<int>(2, 4, 6, 8, 10);
Assert.AreEqual("{2,4,6,8,10}", set.ToString());
set.Add(1, 3, 5, 7, 9);
Assert.AreEqual("{2,4,6,8,10,1,3,5,7,9}", set.ToString());
set.Remove(9);
Assert.AreEqual("{2,4,6,8,10,1,3,5,7}", set.ToString());
}
示例3: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//int il_atomow = (int)numericUpDown1.Value;
string dictSeq =textBox1.Text;
string dictSeq2 = textBox2.Text;
int numberOfAtoms=(int)numericUpDown1.Value;
// Console.WriteLine("Ile atomów?");
// numberOfAtoms = Convert.ToInt32(Console.ReadLine());
//numberOfAtoms = il_atomow;
Valuation val = new Valuation(numberOfAtoms);
Valuation.InterrConn Connn = new Valuation.InterrConn(Program.itIsNecessary);
Valuation.Val Valuation = new Valuation.Val(Program.valVariables);
try
{
string beta = textBox3.Text;
string dictSequence = dictSeq;
string dictSequence_var = dictSeq2;
Dictionary<int, List<int>> Dict =
Program.toDictionary(dictSequence);
Dictionary<string, int[]> Dict_var =
Program.toDictionary_str(dictSequence_var);
Program.setDictNecess(Dict);
Program.setDictValuaVar(Dict_var);
Formula fromBeta = Program.ToFormula(beta);
Set<int> Valua_beta = new Set<int>();
Valua_beta = val.Valua(Connn, Valuation, fromBeta);
if(Valua_beta.Elements.Count!=0)
{
Program.sort(ref Valua_beta);
textBox4.Text = Valua_beta.ToString().Substring(0,Valua_beta.ToString().Length-3)+"}";
}
else textBox4.Text="{}";
}
catch
{
MessageBox.Show("Something is wrong with formats");}
}
示例4: TechnicalTesting
public void TechnicalTesting()
{
var set = new Set<int>(1, 2, 3, 4);
Console.WriteLine(set.ToString());
Console.WriteLine(set.GetHashCode());
Console.WriteLine(set.Equals(new Set<int>(1, 2, 3, 4)));
}
示例5: AddSets
public void AddSets()
{
var a = new Set<int>(1, 2, 3, 4, 5);
var b = new Set<int>(6, 7, 8, 9, 10);
a.Add(b);
Assert.AreEqual("{1,2,3,4,5,6,7,8,9,10}", a.ToString());
}
示例6: SimpleValueTests
public void SimpleValueTests()
{
Set<int> empty = new Set<int>();
Set<int> a = new Set<int>(1, 2, 3);
Set<int> b = new Set<int>(3, 4, 5);
Set<int> a_and_b = a + b;
Assert.AreEqual("{}", empty.ToString());
Assert.AreEqual("{ 1, 2, 3 }", a.ToString());
Assert.AreEqual("{ 3, 4, 5 }", b.ToString());
Assert.AreEqual("{ 1, 2, 3, 4, 5 }", a_and_b.ToString());
Assert.AreEqual("{}", (empty * a).ToString());
Assert.AreEqual("{}", (a * empty).ToString());
Assert.IsTrue(a_and_b * a == a);
Assert.IsTrue((a_and_b * a).Equals(a));
Assert.IsTrue(a_and_b - a == new Set<int>(4, 5));
Assert.IsTrue(a - a == new Set<int>());
Assert.IsTrue(a * a == a);
Assert.IsTrue(a.IsSubsetOf(a_and_b));
Assert.IsTrue(b.IsSubsetOf(a_and_b));
Assert.IsTrue(a_and_b.IsSubsetOf(a_and_b));
Assert.IsTrue(a.IsSubsetOf(a));
Assert.IsTrue(b.IsSubsetOf(b));
Assert.IsFalse(a.IsSubsetOf(b));
Assert.IsFalse(b.IsSubsetOf(a));
Assert.IsFalse(a_and_b.IsSubsetOf(a));
Assert.IsFalse(a_and_b.IsSubsetOf(b));
Set<int> a_copy = a.Copy();
Set<int> b_copy = b.Copy();
a.UnionUpdate(b);
Assert.AreEqual(a, a_and_b);
a.DifferenceUpdate(b);
Assert.AreEqual(a, a_and_b - b);
a.UnionUpdate(9);
Assert.AreEqual(a, (a_and_b - b) + new Set<int>(9));
a.DifferenceUpdate(1);
Assert.AreEqual(a, (a_and_b - b) + new Set<int>(9) - new Set<int>(1));
a_copy.IntersectionUpdate(b_copy);
Assert.AreEqual(new Set<int>(3), a_copy);
}
示例7: splitGoals
internal Pair<Set<CompoundTerm>, Set<Term>> splitGoals(Set<CompoundTerm> goals)
{
Set<CompoundTerm> simpleStateGoals = Set<CompoundTerm>.EmptySet;
Set<Term> fsmStateGoals = Set<Term>.EmptySet;
foreach (CompoundTerm ct in goals)
{
if (ct.FunctionSymbol.ToString() == "FsmState")
{
// We know that FsmState is always represented as "FsmState(Set(0...))".
Term t = ct.Arguments[0];
if (typeof(CompoundTerm) == t.GetType())
{
fsmStateGoals = fsmStateGoals.Add(((CompoundTerm)t).Arguments[0]);
}
}
else if (ct.FunctionSymbol.ToString() == "SimpleState")
{
simpleStateGoals = simpleStateGoals.Add(ct);
}
}
if (goals.Count != fsmStateGoals.Count + simpleStateGoals.Count)
{
Console.Error.WriteLine("Encountered unrecognized goals that are neither FsmState nor SimpleState in " + goals.ToString());
}
Console.WriteLine(fsmStateGoals.ToString());
return new Pair<Set<CompoundTerm>, Set<Term>>(simpleStateGoals, fsmStateGoals);
}
示例8: processGoal
internal Set<CompoundTerm> processGoal(ModelProgram mp, Set<CompoundTerm> goals)
{
Set<CompoundTerm> processedGoals = Set<CompoundTerm>.EmptySet;
if (typeof(LibraryModelProgram) == mp.GetType())
{
//we ignore it for the moment
Console.Error.WriteLine("Goals involving LibraryModelPrograms currently not supported. ");
Console.Error.WriteLine("Currently searching for a match for '" + goals.ToString() + "'. ");
}
else if (typeof(FsmModelProgram) == mp.GetType()) {
FsmModelProgram fsm = (FsmModelProgram)mp;
foreach (CompoundTerm ct in goals)
{
Console.WriteLine("Checking FSM: " + ct.ToString() + "; " + fsm.Name);
if (ct.FunctionSymbol.ToString() == fsm.Name) {
processedGoals = processedGoals.Add(CompoundTerm.Parse("FsmState(Set(" + ct.Arguments[0].ToString() + "))"));
goals = goals.Remove(ct);
}
Console.WriteLine("Current processedGoals: " + processedGoals.ToString());
}
}
else if (typeof(ProductModelProgram) == mp.GetType())
{
ProductModelProgram pmp = (ProductModelProgram)mp;
processedGoals = processedGoals.Union(processGoal(pmp.M1,goals));
processedGoals = processedGoals.Union(processGoal(pmp.M2,goals));
}
return processedGoals;
}
示例9: CheckReachability
//.........这里部分代码省略.........
// IState isomorphicState;
// Transition t;
// if (!visited.HasIsomorphic(targetIState, out isomorphicState))
// {
// frontier = frontier.Add(targetIState);
// //visited = visited.Add(targetIState);
// visited.Add(targetIState);
// t = new Triple<Term, CompoundTerm, Term>(sourceNode, action, targetNode);
// }
// else
// {
// if (collapseExcludedIsomorphicStates)
// t = new Triple<Term, CompoundTerm, Term>(sourceNode, action, nodeMap[isomorphicState]);
// else
// {
// Term isoNode = nodeMap[isomorphicState];
// t = new Triple<Term, CompoundTerm, Term>(sourceNode, action, targetNode);
// if (!targetNode.Equals(sourceNode) && !targetNode.Equals(isoNode))
// groupingTransitions = groupingTransitions.Add(new Triple<Term, CompoundTerm, Term>(targetNode, new CompoundTerm(new Symbol("IsomorphicTo"), new Sequence<Term>()), isoNode));
// }
// }
// this.transitions = this.transitions.Add(t);
// this.hiddenTransitions = this.hiddenTransitions.Remove(t);
// }
// }
//}
////Console.WriteLine(dashedTransitions.ToString());
////Console.WriteLine(visited.ToString());
}
else
{
Set<IState> frontier = new Set<IState>(modelProgram.InitialState);
Console.Out.WriteLine(frontier.ToString());
Console.Out.WriteLine(modelProgram.ToString());
stateCount++;
// need to add a check about the initial state.
Set<IState> visited = new Set<IState>(modelProgram.InitialState);
Set<string> transitionPropertyNames = Set<string>.EmptySet;
TransitionProperties transitionProperties;
while (!frontier.IsEmpty)
{
IState sourceIState = frontier.Choose(0);
frontier = frontier.Remove(sourceIState);
foreach (Symbol aSymbol in this.modelProgram.PotentiallyEnabledActionSymbols(sourceIState))
{
foreach (CompoundTerm action in this.modelProgram.GetActions(sourceIState, aSymbol))
{
//Node targetNode = GetTargetNode(sourceNode, action);
IState targetIState = modelProgram.GetTargetState(sourceIState, action, transitionPropertyNames, out transitionProperties);
//Console.WriteLine(sourceIState.ToString());
//Console.WriteLine ("--- " + action + " --->");
//Console.WriteLine (targetIState.ToString());
//Console.WriteLine();
//Console.WriteLine();
//if (this.modelProgram.IsAccepting(targetIState))
// this.acceptingNodes = this.acceptingNodes.Add(targetNode);
//if (!this.modelProgram.SatisfiesStateInvariant(targetState))
// this.errorNodes = this.errorNodes.Add(targetNode);
//IState isomorphicState;
//Transition t;
transCnt++;
if (!visited.Contains(targetIState))
{
if (GoalsSatisfied(simpleAndFsmGoals, targetIState)) goto end;
frontier = frontier.Add(targetIState);
示例10: SetToStates
private State[] SetToStates(Set set)
{
var statesStrings = set.ToString().Split(new string[] { "Set", "(" }, StringSplitOptions.RemoveEmptyEntries);
var result = new List<State>();
for (var i = 0; i < statesStrings.Length; i++)
{
var stStr = statesStrings[i];
var literals = stStr.Replace("(", "").Replace(")", "").Replace(",", "").Split(' ');
var newState = new State();
foreach (var literal in literals)
{
bool isTrue = !literal.Contains("!");
var prop = literal.Replace("!", "");
if (!string.IsNullOrEmpty(prop)) {
newState.Add(prop, isTrue.NumVal());
}
}
if (newState.Keys.Count > 0) {
result.Add(newState);
}
}
return result.ToArray();
}
示例11: ToStringWithManyElements
public void ToStringWithManyElements() {
var set = new Set<int>();
set.Add(new [] { 1, 2, 3, 4 });
Assert.Equals("{1, 2, 3, 4}", set.ToString());
}
示例12: ToStringWithOneElement
public void ToStringWithOneElement() {
var set = new Set<int>();
set.Add(1);
Assert.Equals("{1}", set.ToString());
}
示例13: ToStringOnEmptySet
public void ToStringOnEmptySet() {
var set = new Set<int>();
Assert.Equals("{}", set.ToString());
}
示例14: GetUnusedArguments
static Set<string> GetUnusedArguments(Set<string> defaultArguments, CompoundTerm action)
{
Set<string> result = defaultArguments;
foreach (Term arg in action.Arguments)
{
if (!arg.Equals(Any.Value))
{
Variable v = arg as Variable;
if (null == v)
throw new ModelProgramUserException("invalid argument for action " + action.ToString() +
": " + arg.ToString());
string name = v.ToString();
if (!defaultArguments.Contains(name))
throw new ModelProgramUserException("invalid (possibly misspelled) argument for action " + action.ToString() +
": " + arg.ToString() + ". Must be one of " + defaultArguments.ToString() + ".");
result = result.Remove(name);
}
}
return result;
}
示例15: Choose
/// <summary>
/// Choose a term from the given set
/// </summary>
public CompoundTerm Choose(Set<CompoundTerm> choices)
{
if (choiceOracle.Count == 0)
throw new ChoiceException(choices);
else if (choices.Contains(choiceOracle.Head))
{
CompoundTerm result = choiceOracle.Head;
choiceOracle = choiceOracle.Tail;
return result;
}
else
{
throw new InvalidOperationException("Value " + choiceOracle.Head.ToString() + " not found in " + choices.ToString());
}
}