本文整理汇总了C#中ISelection类的典型用法代码示例。如果您正苦于以下问题:C# ISelection类的具体用法?C# ISelection怎么用?C# ISelection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISelection类属于命名空间,在下文中一共展示了ISelection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectionIsReadOnly
internal static bool SelectionIsReadOnly(IDocument document, ISelection sel)
{
if (document.TextEditorProperties.SupportReadOnlySegments)
return document.MarkerStrategy.GetMarkers(sel.Offset, sel.Length).Exists(m=>m.IsReadOnly);
else
return false;
}
示例2: AdvanceGeneration
static Population AdvanceGeneration(Population population, ISelection selection, ICrossover crossover, IMutation mutation)
{
var chromosomes = new List<Chromosome>();
population = new Population(population.Take((int)(truncationRate * population.Count()))); // TRUNCATION
chromosomes.AddRange(population.Take((int)(elitismRate * chromosomeCount))); //ELITE (assuming that the chromosomes in the population are sorted by fitness (the fitter are at the top of the list)
do
{
Chromosome chosen1 = selection.Select(population),
chosen2 = selection.Select(population);
if (random.NextDouble() < crossoverRate)
{
var children = crossover.Crossover(chosen1, chosen2); // CROSSOVER
chosen1 = children.Item1;
chosen2 = children.Item2;
}
if (random.NextDouble() < mutationRate)
{
chosen1 = mutation.Mutate(chosen1); // MUTATION
}
if (random.NextDouble() < mutationRate)
{
chosen2 = mutation.Mutate(chosen2); // MUTATION
}
chromosomes.Add(chosen1);
chromosomes.Add(chosen2);
} while (chromosomes.Count < chromosomeCount);
return new Population(chromosomes);
}
示例3: FindJumpInstructionsVisitor
public FindJumpInstructionsVisitor(MethodDeclaration method, ISelection selection)
{
this.method = method;
this.selection = selection;
this.labels = new List<LabelStatement>();
this.cases = new List<CaseLabel>();
}
示例4: Population
public Population(int size, IFitnessFunction fitnessFunction, IReproduction reproductionFunction, INodeMutator mutator, ISelection selection)
{
this.populationSize = size;
this.fitnessFunction = fitnessFunction;
this.reproductionFunction = reproductionFunction;
this.mutator = mutator;
this.selector = selection;
this.fitnessFunction.Initialise();
// Create the initial population
for (int i = 0; i < size; i++)
{
try
{
NodeContext zeroContext = new NodeContext();
zeroContext.AvailableCollections = fitnessFunction.GetCollections();
zeroContext.AvailableInputs = fitnessFunction.GetInputs();
INode candidateNode = NodeFactory.GenerateNode(zeroContext);
// Make sure we have a decent candidate (i.e. not too large)
double fitness = this.fitnessFunction.CalculateFitness(candidateNode);
if (fitness == Double.MaxValue) continue;
this.population.Add(NodeFactory.GenerateNode(zeroContext));
}
catch (StackOverflowException)
{
}
}
}
示例5: Population
/// <summary>
/// Constructor
/// </summary>
public Population(int size,
IIndividual ancestor,
IFitnessFunction fitnessFunction,
ISelection selectionMethod,
int numberIterations)
{
FitnessFunction = fitnessFunction;
Selection = Replacement = selectionMethod;
PopulationSize = size;
firstSelectionCount = size;
firstReplacementCount = ((int)(size / 2)) % 2 == 0 ? (int)(size / 2) : (int)(size / 2) + 1;
iterations = numberIterations;
// Agregar el ancestro a la poblacion
ancestor.Evaluate(fitnessFunction);
Individuals.Add(ancestor);
// Se agregan mas cromosomas a la poblacion
for (int i = 1; i < size; i++)
{
// Se crea un nuevo cromosoma al azar
IIndividual c = ancestor.CreateRandomIndividual();
// se calcula su aptitud
c.Evaluate(fitnessFunction);
// Se lo agrega a la poblacion
Individuals.Add(c);
}
}
示例6: ProxySelection
public ProxySelection(ISelection selection)
{
_selection = selection;
_numberOfGoodStarts = 0;
_numberOfBadStarts = 0;
_progressList = new List<double> { 1 };
_progress = OneHundredPercent;
}
示例7: MethodExtractorBase
public MethodExtractorBase(ICSharpCode.TextEditor.TextEditorControl textEditor, ISelection selection)
{
this.currentDocument = textEditor.Document;
this.textEditor = textEditor;
this.currentSelection = selection;
this.start = new Location(this.currentSelection.StartPosition.Column + 1, this.currentSelection.StartPosition.Line + 1);
this.end = new Location(this.currentSelection.EndPosition.Column + 1, this.currentSelection.EndPosition.Line + 1);
}
示例8: DecreaseSelection
public DecreaseSelection(IDocument document, ISelection selection)
{
if (document == null) throw new ArgumentNullException("document");
if (selection == null) throw new ArgumentNullException("selection");
this.itsDocument = document;
itsOffset = selection.Offset + 1;
itsEndOffset = selection.EndOffset - 1;;
itsSelectedText = document.TextContent.Substring(Offset, EndOffset-Offset);
}
示例9: getProjectFromSelection
public static IProject getProjectFromSelection(ISelection selection) {
var resource = getResourceFromSelection(selection);
if (resource == null) {
return null;
}
if (resource.getType() == IResource.PROJECT) {
return (IProject)resource;
} else {
return resource.getProject();
}
}
示例10: GetComplexArrayFrom1DSelection
public static Complex[] GetComplexArrayFrom1DSelection(ISelection selection) {
int size = selection.Size;
var result = new Complex[size];
var i = 0;
foreach(var v in selection){
result[i] = new Complex(v[0], 0);
i++;
}
return result;
}
示例11: SelectionIsReadOnly
internal static bool SelectionIsReadOnly(IDocument document, ISelection sel)
{
//johnny
//if (document.TextEditorProperties.SupportReadOnlySegments)
// return document.MarkerStrategy.GetMarkers(sel.Offset, sel.Length).Exists(m=>m.IsReadOnly);
if (document.TextEditorProperties.SupportReadOnlySegments)
{
return document.MarkerStrategy.GetMarkers(sel.Offset, sel.Length).Exists(delegate(TextMarker m) { return m.IsReadOnly; });
}
else
return false;
}
示例12: CallAllProperties
internal static void CallAllProperties(ISelection selection)
{
selection.ContainsOffset(0);
selection.ContainsPosition(TextLocation.Empty);
int offset = selection.EndOffset;
TextLocation position = selection.EndPosition;
bool empty = selection.IsEmpty;
bool rectangularSelection = selection.IsRectangularSelection;
int length = selection.Length;
int offset2 = selection.Offset;
string text = selection.SelectedText;
TextLocation startPosition = selection.StartPosition;
}
示例13: ExtendBlockSelection
/// <summary>
/// Initialize a new instance of the ExtendBlockSelection class.
/// </summary>
/// <param name="document">Object that implements the IDocument interface.</param>
/// <param name="selection">The current selection.</param>
public ExtendBlockSelection(IDocument document, ISelection selection)
{
if (document == null)
throw new ArgumentNullException("document");
if (selection == null)
throw new ArgumentNullException("selection");
itsDocument = document;
itsOffset = selection.Offset;
itsEndOffset = selection.EndOffset;
ExtendCurrentSelection();
}
示例14: ReverseSelection
private static ISelection ReverseSelection(ISelection selection)
{
var list = new ArrayList();
if (selection != null && selection.Items != null)
{
foreach (object o in selection.Items)
list.Add(o);
list.Reverse();
}
return new Selection(list);
}
示例15: TwoIslandsPopulation
public TwoIslandsPopulation(int size, IFitnessFunction fitnessFunction, IReproduction reproductionFunction, INodeMutator mutator, ISelection selection)
{
this.populationSize = size;
this.fitnessFunction = fitnessFunction;
this.reproductionFunction = reproductionFunction;
this.mutator = mutator;
this.selector = selection;
this.fitnessFunction.Initialise();
// The main population needs initializing
this.IntialisePopulation(this.mainPopulation);
this.IntialisePopulation(this.secondaryPopulation);
}