private bool ParsePreDocumentFunction(Block token) { switch (token.GrammarSegment) { case GrammarSegment.Url: CastRuleSet <DocumentRule>().Conditions.Add(Tup <DocumentFunction, string> .Create(DocumentFunction.Url, ((StringBlock)token).Value)); break; case GrammarSegment.UrlPrefix: CastRuleSet <DocumentRule>().Conditions.Add(Tup <DocumentFunction, string> .Create(DocumentFunction.UrlPrefix, ((StringBlock)token).Value)); break; case GrammarSegment.Domain: CastRuleSet <DocumentRule>().Conditions.Add(Tup <DocumentFunction, string> .Create(DocumentFunction.Domain, ((StringBlock)token).Value)); break; case GrammarSegment.Function: if (string.Compare(((SymbolBlock)token).Value, "regexp", StringComparison.OrdinalIgnoreCase) == 0) { SetParsingContext(ParsingContext.InDocumentFunction); return(true); } SetParsingContext(ParsingContext.AfterDocumentFunction); return(false); default: SetParsingContext(ParsingContext.DataBlock); return(false); } SetParsingContext(ParsingContext.BetweenDocumentFunctions); return(true); }
public override Control CreateControl(Type dataType) { // Create Tup b = CanHandle2(null, dataType); return(b.Binder.CreateControl(b.Binder.PreferredDataType)); }
public void Basic() { var heading = "SNo:text,SName:text,Status:integer,City:text"; var t1 = Tup.Data("S6", "White", 25, "Sydney"); Assert.AreEqual(4, t1.Degree); Assert.IsTrue(t1.ToString().Contains("White")); Assert.AreEqual(1, t1.Count(v => v.ToString().Contains("White"))); Assert.AreEqual(2, t1.Count(v => v.ToString().Contains("S"))); Assert.AreEqual(t1, t1); var t1a = Tup.Data("S6", "White", 25, "Sydney"); var t2 = Tup.Data("S7", "Black", 15, "London"); Assert.AreEqual(t1, t1a); Assert.AreNotEqual(t1, t2); var sd = RelNode.Data(heading, Tup.Data("S6", "White", 25, "Sydney"), Tup.Data("S7", "Black", 15, "London")); Assert.AreEqual(4, sd.Degree); Assert.AreEqual(2, sd.Cardinality); Assert.AreEqual(1, sd.Count(t => t.ToString().Contains("Black"))); Assert.AreEqual(2, sd.Count(t => t.ToString().Contains("S"))); Assert.AreEqual(sd, sd); var sda = RelNode.Data(heading, t2, t1); Assert.AreEqual(sd.ToRelVar(), sda.ToRelVar()); //Assert.AreEqual(sd.ToRelVar(), sda.ToRelVar()); }
public override object Get(Control control, Type dataType) { // Convert from binder's preferred type Tup b = CanHandle2(control, dataType); object value = b.Binder.Get(control, b.Binder.PreferredDataType); return(b.Converter.ConvertFrom(value)); }
public override void Set(Control control, object value, Type dataType) { // Convert to binder's preferred type Tup b = CanHandle2(control, dataType); value = b.Converter.ConvertTo(value, b.Binder.PreferredDataType); b.Binder.Set(control, value, b.Binder.PreferredDataType); }
public int solution(int[] A) { // write your code in C# 5.0 with .NET 4.5 (Mono) int N = A.Length; Queue <Tup> Q = new Queue <Tup>(); Q.Enqueue(new Tup(-1, -1, 0, -4)); while (Q.Any()) { Tup t = Q.Dequeue(); if (isFab(t.mid - t.start) && isFab(N - t.mid)) { Console.WriteLine(t.prev + " | " + t.start + " : " + t.mid + " : " + (N - t.mid)); return(t.Depth + 1); } else if (t.Depth == 0) { for (int i = t.mid + 1; i < A.Length; i++) { if (A[i] == 1) { Tup nT = new Tup(t.mid, i, t.Depth + 1, t.start); if (myFab(i) < N) { Q.Enqueue(nT); } else { break; } //Console.WriteLine(i); } } } else if (isFab(t.mid - t.start)) { for (int i = t.mid + 1; i < A.Length; i++) { if (A[i] == 1) { Tup nT = new Tup(t.mid, i, t.Depth + 1, t.start); if (myFab(i) < N) { Q.Enqueue(nT); } else { break; } //Console.WriteLine(i); } } } } return(-1); }
public static Tup <T1, T2> Create(T1 item1, T2 item2) { Tup <T1, T2> tuple = new Tup <T1, T2>() { Item1 = item1, Item2 = item2 }; return(tuple); }
private bool ParseDocumentFunction(Block token) { SetParsingContext(ParsingContext.AfterDocumentFunction); if (token.GrammarSegment != GrammarSegment.String) { return(false); } CastRuleSet <DocumentRule>().Conditions.Add(Tup <DocumentFunction, string> .Create(DocumentFunction.RegExp, ((StringBlock)token).Value)); return(true); }
public int solution(int[] A) { // write your code in C# 5.0 with .NET 4.5 (Mono) int N = A.Length; Queue<Tup> Q = new Queue<Tup>(); Q.Enqueue(new Tup(-1,-1,0,-4)); while(Q.Any()) { Tup t = Q.Dequeue(); if (isFab(t.mid - t.start) && isFab(N - t.mid)) { Console.WriteLine(t.prev + " | " + t.start + " : " + t.mid + " : " + (N - t.mid)); return t.Depth + 1; } else if (t.Depth == 0) { for (int i = t.mid + 1; i < A.Length; i++) { if (A[i] == 1) { Tup nT = new Tup(t.mid, i, t.Depth + 1, t.start); if (myFab(i) < N) Q.Enqueue(nT); else break; //Console.WriteLine(i); } } } else if (isFab(t.mid - t.start)) { for (int i = t.mid + 1; i < A.Length; i++) { if (A[i] == 1) { Tup nT = new Tup(t.mid, i, t.Depth + 1, t.start); if (myFab(i) < N) Q.Enqueue(nT); else break; //Console.WriteLine(i); } } } } return -1; }
/// <summary> /// Creates normals for the OPC in opcBasePath and saves them as Normals.aara. /// </summary> public static void BuildNormals(OpcPaths opcPaths, bool overrideExisting = false, IObserver <Tup <float, string> > progress = null, CancellationToken cancelToken = default(CancellationToken)) { var normalFileName = "Normals.aara"; var posFiles = StorageConfig.GetDirectories(opcPaths.PatchesSubDir) .SelectMany(x => StorageConfig.GetFiles(x)) .Where(fileWpath => fileWpath.EndsWith("Positions.aara", StringComparison.OrdinalIgnoreCase)); foreach (var file in posFiles) { if (cancelToken.IsCancellationRequested) { if (progress != null) { progress.OnNext(Tup.Create(0f, "Building normals cancelled.")); progress.OnCompleted(); } cancelToken.ThrowIfCancellationRequested(); } var normalsFilePath = Path.Combine(Path.GetDirectoryName(file), normalFileName); if (overrideExisting || !StorageConfig.FileExists(normalsFilePath)) { var posAara = AaraData.FromFile(file); var tileSize = new V2i(posAara.Size[0], posAara.Size[1]); var posArray = AaraData.ConvertArrayToV3ds[posAara.DataTypeAsSymbol](posAara.LoadElements()); var invalidPoints = OpcIndices.GetInvalidPositions(posArray); var indices = OpcIndices.ComputeIndexArray(tileSize, invalidPoints); var normals = OpcIndices.GenerateVertexNormals(indices, posArray) .Select(p => p.ToV3f()).ToArray(); WriteV3fArrayAsAara(normalsFilePath, normals, tileSize); } if (progress != null) { progress.OnNext(Tup.Create(1f / posFiles.Count(), "")); } } if (progress != null) { progress.OnCompleted(); } }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj.GetType() != GetType()) { return(false); } Tup <T1, T2> other = (Tup <T1, T2>)obj; return(Equals(Item1, other.Item1) && Equals(Item2, other.Item2)); }
public static FieldCoder[] Get(int coderVersion, Type type, int version, IFieldCodeable fieldCodeAble) { var key = Tup.Create(coderVersion, type, version); FieldCoder[] fieldCoderArray; lock (s_lock) { if (!s_fieldCoderArrayMap.TryGetValue(key, out fieldCoderArray)) { fieldCoderArray = fieldCodeAble.GetFieldCoders(coderVersion) .OrderBy(fc => fc.Order) .Where(fc => fc.MinVersion <= version && version <= fc.MaxVersion) .ToArray(); s_fieldCoderArrayMap[key] = fieldCoderArray; } } return(fieldCoderArray); }
/// <summary> /// Deletes *.dds in an opc directory (if *.tif exists). /// </summary> public static int DeleteDDSs(OpcPaths opcPaths, IProgress <Tup <float, string> > progress = null) { int deleteCounter = 0; var files = StorageConfig.GetDirectories(opcPaths.ImagesSubDir) .SelectMany(x => StorageConfig.GetFiles(x)) .Where(x => Path.GetExtension(x) == ".dds"); if (files.IsEmptyOrNull()) { if (progress != null) { progress.Report(Tup.Create(1f, "No dds images found.")); } return(0); } var inc = 1f / files.Count(); foreach (var f in files) { string tifPath = Path.ChangeExtension(f, ".tif"); var msg = ""; if (StorageConfig.FileExists(tifPath)) { File.Delete(f); deleteCounter++; } else { msg = "dds file not deleted, because it doesn't have a coresponding tif file (" + f + ")"; } if (progress != null) { progress.Report(Tup.Create(inc, msg)); } } return(deleteCounter); }
/// <summary> /// Returns a column in the range of rowStart to rowEnd. Warning: This is slow, because elemnts have to been seeked out. /// </summary> /// <param name="columnPos">Column to read.</param> /// <param name="rowStart"></param> /// <param name="rowEnd"></param> /// <returns></returns> public Array LoadColumn(int columnPos, int rowStart, int rowEnd) { using (s_cpu_AaraDataReadMemoryStream.Timer) { var readFun = s_readBigFuncs[DataTypeAsSymbol]; var byteSize = s_sizeTable[DataTypeAsSymbol]; var rowCount = rowEnd - rowStart; var byteOffset = HeaderSize + byteSize * columnPos; var byteStride = byteSize * NumOfColumns; // load from file to memory var chunks = Enumerable.Range(0, rowCount).Select(i => Tup.Create((long)(byteOffset + i * byteStride), (long)byteSize)); var memStream = Load.AsMemoryStream(SourceFileName, chunks); // convert from memory stream to actual data var r = readFun(new StreamCodeReader(memStream), rowCount); return(r); } }
public static FieldCoderMap Get(int coderVersion, Type type, int version, IFieldCodeable fieldCodeAble) { var key = Tup.Create(coderVersion, type, version); FieldCoderMap fieldCoderMap; lock (s_lock) { if (!s_fieldCoderMapMap.TryGetValue(key, out fieldCoderMap)) { fieldCoderMap = new FieldCoderMap(); var fieldCoders = fieldCodeAble.GetFieldCoders(coderVersion) .Where(fc => fc.MinVersion <= version && version <= fc.MaxVersion); foreach (var fc in fieldCoders) { fieldCoderMap[fc.Name] = fc.Code; } s_fieldCoderMapMap[key] = fieldCoderMap; } } return(fieldCoderMap); }
/** Static constructor. */ static Parser() { FieldParser SFBool = new FieldParser(ParseSFBool); //FieldParser MFBool = new FieldParser(ParseMFBool); FieldParser SFColor = new FieldParser(ParseSFColor); FieldParser MFColor = new FieldParser(ParseMFColor); FieldParser SFFloat = new FieldParser(ParseSFFloat); FieldParser MFFloat = new FieldParser(ParseMFFloat); FieldParser SFImage = new FieldParser(ParseSFImage); FieldParser SFInt32 = new FieldParser(ParseSFInt32); FieldParser MFInt32 = new FieldParser(ParseMFInt32); FieldParser SFNode = new FieldParser(ParseSFNode); FieldParser MFNode = new FieldParser(ParseMFNode); FieldParser SFRotation = new FieldParser(ParseSFRotation); FieldParser MFRotation = new FieldParser(ParseMFRotation); FieldParser SFString = new FieldParser(ParseSFString); FieldParser MFString = new FieldParser(ParseMFString); FieldParser SFTime = new FieldParser(ParseSFFloat); //FieldParser MFTime = new FieldParser(ParseMFFloat); FieldParser SFVec2f = new FieldParser(ParseSFVec2f); FieldParser MFVec2f = new FieldParser(ParseMFVec2f); FieldParser SFVec3f = new FieldParser(ParseSFVec3f); FieldParser MFVec3f = new FieldParser(ParseMFVec3f); // Dictionary<string, Tup<FieldParser, object>> fields; // Lookup table for Vrml97 node types. // For each node type a NodeParseInfo entry specifies how // to handle this kind of node. m_parseInfoMap = new SymbolDict <NodeParseInfo>(); // DEF m_parseInfoMap[Vrml97Sym.DEF] = new NodeParseInfo(new NodeParser(ParseDEF)); // USE m_parseInfoMap[Vrml97Sym.USE] = new NodeParseInfo(new NodeParser(ParseUSE)); // ROUTE m_parseInfoMap[Vrml97Sym.ROUTE] = new NodeParseInfo(new NodeParser(ParseROUTE)); // NULL m_parseInfoMap[Vrml97Sym.NULL] = new NodeParseInfo(new NodeParser(ParseNULL)); var defaultBBoxCenter = Tup.Create(SFVec3f, (object)V3f.Zero); var defaultBBoxSize = Tup.Create(SFVec3f, (object)new V3f(-1, -1, -1)); Func <FieldParser, object, Tup <FieldParser, object> > fdd = (fp, obj) => Tup.Create(fp, obj); Func <FieldParser, Tup <FieldParser, object> > fd = fp => new Tup <FieldParser, object>(fp, null); // Anchor m_parseInfoMap["Anchor"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "children", fd(MFNode) }, { "description", fd(SFString) }, { "parameter", fd(MFString) }, { "url", fd(MFString) }, { "bboxCenter", defaultBBoxCenter }, { "bboxSize", defaultBBoxSize } }); // Appearance m_parseInfoMap["Appearance"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "material", fd(SFNode) }, { "texture", fd(SFNode) }, { "textureTransform", fd(SFNode) } }); // AudioClip m_parseInfoMap["AudioClip"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "description", fd(SFString) }, { "loop", fdd(SFBool, false) }, { "pitch", fdd(SFFloat, 1.0f) }, { "startTime", fdd(SFTime, 0.0f) }, { "stopTime", fdd(SFTime, 0.0f) }, { "url", fd(MFString) } }); // Background m_parseInfoMap["Background"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "groundAngle", fd(MFFloat) }, { "groundColor", fd(MFColor) }, { "backUrl", fd(MFString) }, { "bottomUrl", fd(MFString) }, { "frontUrl", fd(MFString) }, { "leftUrl", fd(MFString) }, { "rightUrl", fd(MFString) }, { "topUrl", fd(MFString) }, { "skyAngle", fd(MFFloat) }, { "skyColor", fdd(MFColor, C3f.Black) } }); // Billboard m_parseInfoMap["Billboard"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "axisOfRotation", fdd(SFVec3f, new V3f(0.0f, 1.0f, 0.0f)) }, { "children", fd(MFNode) }, { "bboxCenter", defaultBBoxCenter }, { "bboxSize", defaultBBoxSize } }); // Box m_parseInfoMap["Box"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "size", fdd(SFVec3f, new V3f(2.0f, 2.0f, 2.0f)) } }); // Collision m_parseInfoMap["Collision"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "children", fd(MFNode) }, { "collide", fdd(SFBool, true) }, { "bboxCenter", defaultBBoxCenter }, { "bboxSize", defaultBBoxSize }, { "proxy", fd(SFNode) } }); // Color m_parseInfoMap["Color"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "color", fd(MFColor) } }); // ColorInterpolator m_parseInfoMap["ColorInterpolator"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "key", fd(MFFloat) }, { "keyValue", fd(MFColor) } }); // Cone m_parseInfoMap["Cone"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "bottomRadius", fdd(SFFloat, 1.0f) }, { "height", fdd(SFFloat, 2.0f) }, { "side", fdd(SFBool, true) }, { "bottom", fdd(SFBool, true) } }); // Coordinate m_parseInfoMap["Coordinate"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "point", fd(MFVec3f) } }); // CoordinateInterpolator m_parseInfoMap["CoordinateInterpolator"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "key", fd(MFFloat) }, { "keyValue", fd(MFVec3f) } }); // Cylinder m_parseInfoMap["Cylinder"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "bottom", fdd(SFBool, true) }, { "height", fdd(SFFloat, 2.0f) }, { "radius", fdd(SFFloat, 1.0f) }, { "side", fdd(SFBool, true) }, { "top", fdd(SFBool, true) } }); // CylinderSensor m_parseInfoMap["CylinderSensor"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "autoOffset", fdd(SFBool, true) }, { "diskAngle", fdd(SFFloat, 0.262f) }, { "enabled", fdd(SFBool, true) }, { "maxAngle", fdd(SFFloat, -1.0f) }, { "minAngle", fdd(SFFloat, 0.0f) }, { "offset", fdd(SFFloat, 0.0f) } }); // DirectionalLight m_parseInfoMap["DirectionalLight"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "ambientIntensity", fdd(SFFloat, 0.0f) }, { "color", fdd(SFColor, C3f.White) }, { "direction", fdd(SFVec3f, new V3f(0.0f, 0.0f, -1.0f)) }, { "intensity", fdd(SFFloat, 1.0f) }, { "on", fdd(SFBool, true) } }); // ElevationGrid m_parseInfoMap["ElevationGrid"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "color", fd(SFNode) }, { "normal", fd(SFNode) }, { "texCoord", fd(SFNode) }, { "height", fd(MFFloat) }, { "ccw", fdd(SFBool, true) }, { "colorPerVertex", fdd(SFBool, true) }, { "creaseAngle", fdd(SFFloat, 0.0f) }, { "normalPerVertex", fdd(SFBool, true) }, { "solid", fdd(SFBool, true) }, { "xDimension", fdd(SFInt32, 0) }, { "xSpacing", fdd(SFFloat, 1.0f) }, { "zDimension", fdd(SFInt32, 0) }, { "zSpacing", fdd(SFFloat, 1.0f) } }); // Extrusion m_parseInfoMap["Extrusion"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "beginCap", fdd(SFBool, true) }, { "ccw", fdd(SFBool, true) }, { "convex", fdd(SFBool, true) }, { "creaseAngle", fdd(SFFloat, 0.0f) }, { "crossSection", fdd(MFVec2f, new List <V2f>() { new V2f(1.0f, 1.0f), new V2f(1.0f, -1.0f), new V2f(-1.0f, -1.0f), new V2f(-1.0f, 1.0f), new V2f(1.0f, 1.0f) }) }, { "endCap", fdd(SFBool, true) }, { "orientation", fdd(MFRotation, new V4f(0.0f, 0.0f, 1.0f, 0.0f)) }, { "scale", fdd(MFVec2f, new V2f(1.0f, 1.0f)) }, { "solid", fdd(SFBool, true) }, { "spine", fdd(MFVec3f, new List <V3f>() { V3f.Zero, new V3f(0.0f, 1.0f, 0.0f) }) } }); // Fog m_parseInfoMap["Fog"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "color", fdd(SFColor, C3f.White) }, { "fogType", fdd(SFString, "LINEAR") }, { "visibilityRange", fdd(SFFloat, 0.0f) } }); // FontStyle m_parseInfoMap["FontStyle"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "family", fdd(MFString, "SERIF") }, { "horizontal", fdd(SFBool, true) }, { "justify", fdd(MFString, "BEGIN") }, { "language", fd(SFString) }, { "leftToRight", fdd(SFBool, true) }, { "size", fdd(SFFloat, 1.0f) }, { "spacing", fdd(SFFloat, 1.0f) }, { "style", fdd(SFString, "PLAIN") }, { "topToBottom", fdd(SFBool, true) } }); // Group m_parseInfoMap["Group"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "children", fd(MFNode) }, { "bboxCenter", defaultBBoxCenter }, { "bboxSize", defaultBBoxSize } }); // ImageTexture m_parseInfoMap["ImageTexture"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "url", fd(MFString) }, { "repeatS", fdd(SFBool, true) }, { "repeatT", fdd(SFBool, true) } }); // IndexedFaceSet m_parseInfoMap["IndexedFaceSet"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "color", fd(SFNode) }, { "coord", fd(SFNode) }, { "normal", fd(SFNode) }, { "texCoord", fd(SFNode) }, { "ccw", fdd(SFBool, true) }, { "colorIndex", fd(MFInt32) }, { "colorPerVertex", fdd(SFBool, true) }, { "convex", fdd(SFBool, true) }, { "coordIndex", fd(MFInt32) }, { "creaseAngle", fdd(SFFloat, 0.0f) }, { "normalIndex", fd(MFInt32) }, { "normalPerVertex", fdd(SFBool, true) }, { "solid", fdd(SFBool, true) }, { "texCoordIndex", fd(MFInt32) }, { "edgeSharpness", fd(MFFloat) }, { "edgeSharpnessIndex", fd(MFInt32) }, { "neighborMesh", fd(MFString) }, { "neighborIndex", fd(MFInt32) }, { "neighborSide", fd(MFInt32) }, { "neighborFace", fd(MFInt32) }, { "meshName", fd(SFString) }, { "topologyHoles", fd(SFInt32) } }); // IndexedLineSet m_parseInfoMap["IndexedLineSet"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "color", fd(SFNode) }, { "coord", fd(SFNode) }, { "colorIndex", fd(MFInt32) }, { "colorPerVertex", fdd(SFBool, true) }, { "coordIndex", fd(MFInt32) } }); // Inline m_parseInfoMap["Inline"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "url", fd(MFString) }, { "bboxCenter", defaultBBoxCenter }, { "bboxSize", defaultBBoxSize } }); // LOD m_parseInfoMap["LOD"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "level", fd(MFNode) }, { "center", defaultBBoxCenter }, { "range", fd(MFFloat) } }); // Material m_parseInfoMap["Material"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "ambientIntensity", fdd(SFFloat, 0.2f) }, { "diffuseColor", fdd(SFColor, new C3f(0.8f, 0.8f, 0.8f)) }, { "emissiveColor", fdd(SFColor, C3f.Black) }, { "shininess", fdd(SFFloat, 0.2f) }, { "specularColor", fdd(SFColor, C3f.Black) }, { "transparency", fdd(SFFloat, 0.0f) } }); // MovieTexture m_parseInfoMap["MovieTexture"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "loop", fdd(SFBool, false) }, { "speed", fdd(SFFloat, 1.0f) }, { "startTime", fdd(SFTime, 1.0f) }, { "stopTime", fdd(SFTime, 1.0f) }, { "url", fd(MFString) }, { "repeatS", fdd(SFBool, true) }, { "repeatT", fdd(SFBool, true) } }); // NavigationInfo m_parseInfoMap["NavigationInfo"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "avatarSize", fdd(MFFloat, new List <float>() { 0.25f, 1.6f, 0.75f }) }, { "headlight", fdd(SFBool, true) }, { "speed", fdd(SFFloat, 1.0f) }, { "type", fdd(MFString, new List <string>() { "WALK", "ANY" }) }, { "visibilityLimit", fdd(SFFloat, 0.0f) } }); // Normal m_parseInfoMap["Normal"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "vector", fd(MFVec3f) } }); // NormalInterpolator m_parseInfoMap["NormalInterpolator"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "key", fd(MFFloat) }, { "keyValue", fd(MFVec3f) } }); // OrientationInterpolator m_parseInfoMap["OrientationInterpolator"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "key", fd(MFFloat) }, { "keyValue", fd(MFRotation) } }); // PixelTexture m_parseInfoMap["PixelTexture"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "image", fdd(SFImage, new List <uint>() { 0, 0, 0 }) }, { "repeatS", fdd(SFBool, true) }, { "repeatT", fdd(SFBool, true) } }); // PlaneSensor m_parseInfoMap["PlaneSensor"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "autoOffset", fdd(SFBool, true) }, { "enabled", fdd(SFBool, true) }, { "maxPosition", fdd(SFVec2f, new V2f(-1.0f, -1.0f)) }, { "minPosition", fdd(SFVec2f, V2f.Zero) }, { "offset", defaultBBoxCenter } }); // PointLight m_parseInfoMap["PointLight"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "ambientIntensity", fdd(SFFloat, 0.0f) }, { "attenuation", fdd(SFVec3f, new V3f(1.0f, 0.0f, 0.0f)) }, { "color", fdd(SFColor, C3f.White) }, { "intensity", fdd(SFFloat, 1.0f) }, { "location", defaultBBoxCenter }, { "on", fdd(SFBool, true) }, { "radius", fdd(SFFloat, 100.0f) } }); // PointSet m_parseInfoMap["PointSet"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "color", fd(SFNode) }, { "coord", fd(SFNode) } }); // PositionInterpolator m_parseInfoMap["PositionInterpolator"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "key", fd(MFFloat) }, { "keyValue", fd(MFVec3f) } }); // ProximitySensor m_parseInfoMap["ProximitySensor"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "center", defaultBBoxCenter }, { "size", defaultBBoxCenter }, { "enabled", fdd(SFBool, true) } }); // ScalarInterpolator m_parseInfoMap["ScalarInterpolator"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "key", fd(MFFloat) }, { "keyValue", fd(MFFloat) } }); // Script // skipped // Shape m_parseInfoMap["Shape"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "appearance", fd(SFNode) }, { "geometry", fd(SFNode) }, }); // Sound m_parseInfoMap["Sound"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "direction", fdd(SFVec3f, new V3f(0.0f, 0.0f, 1.0f)) }, { "intensity", fdd(SFFloat, 1.0f) }, { "location", defaultBBoxCenter }, { "maxBack", fdd(SFFloat, 10.0f) }, { "maxFront", fdd(SFFloat, 10.0f) }, { "minBack", fdd(SFFloat, 1.0f) }, { "minFront", fdd(SFFloat, 1.0f) }, { "priority", fdd(SFFloat, 0.0f) }, { "source", fd(SFNode) }, { "spatialize", fdd(SFBool, true) } }); // Sphere m_parseInfoMap["Sphere"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "radius", fdd(SFFloat, 1.0f) } }); // SphereSensor m_parseInfoMap["SphereSensor"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "autoOffset", fdd(SFBool, true) }, { "enabled", fdd(SFBool, true) }, { "offset", fdd(SFRotation, new V4f(0.0f, 1.0f, 0.0f, 0.0f)) } }); // SpotLight m_parseInfoMap["SpotLight"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "ambientIntensity", fdd(SFFloat, 0.0f) }, { "attenuation", fdd(SFVec3f, new V3f(1.0f, 0.0f, 0.0f)) }, { "beamWidth", fdd(SFFloat, 1.570796f) }, { "color", fdd(SFColor, C3f.White) }, { "cutOffAngle", fdd(SFFloat, 0.785398f) }, { "direction", fdd(SFVec3f, new V3f(0.0f, 0.0f, -1.0f)) }, { "intensity", fdd(SFFloat, 1.0f) }, { "location", defaultBBoxCenter }, { "on", fdd(SFBool, true) }, { "radius", fdd(SFFloat, 100.0f) } }); // Switch m_parseInfoMap["Switch"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "choice", fd(MFNode) }, { "whichChoice", fdd(SFInt32, -1) } }); // Text m_parseInfoMap["Text"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "string", fd(MFString) }, { "fontStyle", fd(SFNode) }, { "length", fd(MFFloat) }, { "maxExtent", fdd(SFFloat, 0.0f) } }); // TextureCoordinate m_parseInfoMap["TextureCoordinate"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "point", fd(MFVec2f) } }); // TextureTransform m_parseInfoMap["TextureTransform"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "center", fdd(SFVec2f, V2f.Zero) }, { "rotation", fdd(SFFloat, 0.0f) }, { "scale", fdd(SFVec2f, new V2f(1.0f, 1.0f)) }, { "translation", fdd(SFVec2f, V2f.Zero) } }); // TimeSensor m_parseInfoMap["TimeSensor"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "cycleInterval", fdd(SFTime, 1.0f) }, { "enabled", fdd(SFBool, true) }, { "loop", fdd(SFBool, false) }, { "startTime", fdd(SFTime, 0.0f) }, { "stopTime", fdd(SFTime, 0.0f) } }); // TouchSensor m_parseInfoMap["TouchSensor"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "enabled", fdd(SFBool, true) } }); // Transform m_parseInfoMap["Transform"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "center", defaultBBoxCenter }, { "children", fd(MFNode) }, { "rotation", fdd(SFRotation, new V4f(0.0f, 0.0f, 1.0f, 0.0f)) }, { "scale", fdd(SFVec3f, new V3f(1.0f, 1.0f, 1.0f)) }, { "scaleOrientation", fdd(SFRotation, new V4f(0.0f, 0.0f, 1.0f, 0.0f)) }, { "translation", defaultBBoxCenter }, { "bboxCenter", defaultBBoxCenter }, { "bboxSize", defaultBBoxSize } }); // Viewpoint m_parseInfoMap["Viewpoint"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "fieldOfView", fdd(SFFloat, 0.785398f) }, { "jump", fdd(SFBool, true) }, { "orientation", fdd(SFRotation, new V4f(0.0f, 0.0f, 1.0f, 0.0f)) }, { "position", fdd(SFVec3f, new V3f(0.0f, 0.0f, 10.0f)) }, { "description", fd(SFString) } }); // VisibilitySensor m_parseInfoMap["VisibilitySensor"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "center", defaultBBoxCenter }, { "enabled", fdd(SFBool, true) }, { "size", defaultBBoxCenter } }); // WorldInfo m_parseInfoMap["WorldInfo"] = new NodeParseInfo( new SymbolDict <Tup <FieldParser, object> >() { { "title", fd(SFString) }, { "info", fd(MFString) } }); }
public static void Add( Type type, int version, Type targetType, Type newestType, Action <Convertible, Convertible> converter) { lock (s_lock) { TypeInfo.Add(type, version); TypeInfo typeInfo = TypeInfo.OfType[type]; List <Type> oldTypes; if (s_oldTypeListOfType.TryGetValue(typeInfo.Type, out oldTypes)) { foreach (var oldType in oldTypes) { typeInfo.AddVersion(TypeInfo.OfType[oldType]); } s_oldTypeListOfType.Remove(typeInfo.Type); } Tup <string, Action <Convertible, Convertible> > conversion; if (s_conversionOfTargetType.TryGetValue(typeInfo.Type, out conversion)) { Converter.Global.Register(conversion.E0, typeInfo.Name, conversion.E1); s_conversionOfTargetType.Remove(typeInfo.Type); } if (newestType == null) { return; } TypeInfo newestTypeInfo; if (!TypeInfo.OfType.TryGetValue(newestType, out newestTypeInfo)) { List <Type> oldTypeList; if (!s_oldTypeListOfType.TryGetValue(newestType, out oldTypeList)) { oldTypeList = new List <Type>(); s_oldTypeListOfType.Add(newestType, oldTypeList); } oldTypeList.Add(type); } else { newestTypeInfo.AddVersion(typeInfo); } TypeInfo targetTypeInfo; if (!TypeInfo.OfType.TryGetValue(targetType, out targetTypeInfo)) { s_conversionOfTargetType.Add(targetType, Tup.Create(typeInfo.Name, converter)); } else { Converter.Global.Register(typeInfo.Name, targetTypeInfo.Name, converter); } } }
public override void InitialiseControl(Control control, Type dataType) { Tup b = CanHandle2(control, dataType); b.Binder.InitialiseControl(control, dataType); }
/// <summary> /// Builds look up table for profile "intersection" in 2d data. /// </summary> public static void BuildLookUpTable(OpcPaths opcPaths, bool overrideExisting = false, IObserver <Tup <float, string> > progress = null, CancellationToken cancelToken = default(CancellationToken)) { if (!overrideExisting && StorageConfig.FileExists(opcPaths.ProfileLutPath)) { if (progress != null) { progress.OnNext(Tup.Create(1f, "")); progress.OnCompleted(); } Report.Line("LookUpTable already exists at {0}", opcPaths.ProfileLutPath); } // PatchHierarchyInfo var info = PatchHierarchyInfo.BuildOrLoadCache(opcPaths); info.PatchTree.CreatePatchPaths(opcPaths.PatchesSubDir); // Level 0 Patches var lvl0Patches = info.RetrievePatchTreesOfLevel(0); if (progress != null) { progress.OnNext(Tup.Create(.1f, "")); } // group by BB-2d: Min-X, Max-X var patchesGroupedByBB = lvl0Patches .GroupBy(patchTree => Tup.Create(patchTree.Info.GlobalBoundingBox2d.Min.X, patchTree.Info.GlobalBoundingBox2d.Max.X)).ToArray(); var entries = new List <ProfileLookUpTableEntry>(); #region Create ProfileLookUpTableEntries for (int index = 0; index < patchesGroupedByBB.Count(); index++) { if (cancelToken.IsCancellationRequested) { if (progress != null) { progress.OnNext(Tup.Create(0f, "Building LookUpTabele cancelled.")); } cancelToken.ThrowIfCancellationRequested(); } //sort patches according to their b (sv_b_r) value var patchesGroupedBySvBR = patchesGroupedByBB[index] .OrderBy(k => k.Info.GlobalBoundingBox2d.Min.Y); var fileHandleList = new List <PatchFileHandle>(); #region build PatchFileHandles foreach (var patchTree in patchesGroupedBySvBR) { if (patchTree.Info.Positions2d.IsNullOrEmpty()) { Report.Warn("ProfileLutCreation: Skipping Patchtree {0}, because of missing 2d positions.", patchTree.Id); if (progress != null) { progress.OnNext(Tup.Create(0f, "ProfileLutCreation: Skipping Patchtree " + patchTree.Id + ", because of missing 2d positions.")); } continue; } var pos2dPath = patchTree.GetPositionPath(PositionsType.V2dPositions); //CAUTION absolute path needs to be repaired during loading var file = AaraData.FromFile(pos2dPath); file.SourceFileName = string.Empty; fileHandleList.Add(new PatchFileHandle() { PatchTree = patchTree, FileLoader = file, }); } #endregion // Create ProfileLookupTableEntries var firstPatchBB = patchesGroupedBySvBR.First().Info.GlobalBoundingBox2d; entries.Add(new ProfileLookUpTableEntry() { Index = index, SvRange = new Range1d(firstPatchBB.Min.X, firstPatchBB.Max.X), FileHandles = fileHandleList, }); var progressInc = 0.8f / patchesGroupedByBB.Count(); if (progress != null) { progress.OnNext(Tup.Create(progressInc, "")); } } entries.Reverse(); #endregion #region Save LUT var lut = new ProfileLookUpTable() { SvRange = new Range1d(info.PatchTree.Info.GlobalBoundingBox2d.Min.X, info.PatchTree.Info.GlobalBoundingBox2d.Max.X), Entries = entries, AvgGeomtrySize = info.AvgGeometrySizes.First() }; lut.Save(opcPaths.ProfileLutPath); #endregion if (progress != null) { progress.OnNext(Tup.Create(0.1f, "")); progress.OnCompleted(); } }
public TupGrouping(TKey1 key1, TKey2 key2, IEnumerable <TElement> elements) { Key = new Tup <TKey1, TKey2>(key1, key2); Elements = elements; }
public void DetailedSortTests(int arrayCount, int minimalCount, double countFactor) { // re-order this array to see certain results first var arrayCreators = new Func <long, SortArray>[] { c => new SortArray <int>(c, i => (int)i, ICmp), c => new SortArray <long>(c, i => i, LCmp), c => new SortArray <float>(c, i => i, FCmp), c => new SortArray <double>(c, i => i, DCmp), c => new FunSortArray <V2d>(c, i => new V2d(0, i), V2dCmp), c => new FunSortArray <V3d>(c, i => new V3d(0, 0, i), V3dCmp), c => new PermSortArray <int, int>(c, i => (int)i, i => i, i => (int)i, ICmp), c => new PermSortArray <int, long>(c, i => (int)i, i => i, i => i, LCmp), c => new PermSortArray <int, float>(c, i => (int)i, i => i, i => i, FCmp), c => new PermSortArray <int, double>(c, i => (int)i, i => i, i => i, DCmp), c => new PermFunSortArray <int, V2d>(c, i => (int)i, i => i, i => new V2d(0, i), V2dCmp), c => new PermFunSortArray <int, V3d>(c, i => (int)i, i => i, i => new V3d(0, 0, i), V3dCmp), c => new PermSortArray <long, int>(c, i => i, i => i, i => (int)i, ICmp), c => new PermSortArray <long, long>(c, i => i, i => i, i => i, LCmp), c => new PermSortArray <long, float>(c, i => i, i => i, i => i, FCmp), c => new PermSortArray <long, double>(c, i => i, i => i, i => i, DCmp), c => new PermFunSortArray <long, V2d>(c, i => i, i => i, i => new V2d(0, i), V2dCmp), c => new PermFunSortArray <long, V3d>(c, i => i, i => i, i => new V3d(0, 0, i), V3dCmp), }; const int seed = 19680713; Action <long[], long, long, long, double> randomFraction = (a, count, repeat, total, fraction) => { var rc = (long)(count * fraction); var rnd = new RandomSystem(seed); for (long s = 0; s < total; s += count) { for (long r = rc; r > 0; r--) { long i = -1; do { i = s + rnd.UniformLong(count); } while (a[i] < 0); long j = -1; do { j = s + rnd.UniformLong(count); } while (j == i); var aj = a[j]; if (aj >= 0) { --r; aj = -1 - aj; } var ai = -1 - a[i]; a[i] = aj; a[j] = ai; } } a.Apply(v => v < 0 ? -1 - v : v); }; // re-order this array to see certain results first var initializers = new Initializer[] { new Initializer("randomized", (a, c, r, t) => { a.SetByIndexLong(t, i => i); new RandomSystem(seed).Randomize(a, t); }), new Initializer("sorted", (a, c, r, t) => a.SetByIndexLong(t, i => i)), new Initializer("sorted, 1% random", (a, c, r, t) => { a.SetByIndexLong(t, i => i); randomFraction(a, c, r, t, 0.01); }), new Initializer("sorted, 10% random", (a, c, r, t) => { a.SetByIndexLong(t, i => i); randomFraction(a, c, r, t, 0.1); }), new Initializer("sorted, 30% random", (a, c, r, t) => { a.SetByIndexLong(t, i => i); randomFraction(a, c, r, t, 0.3); }), new Initializer("reversed", (a, c, r, t) => a.SetByIndexLong(t, i => t - 1 - i)), new Initializer("reversed, 1% random", (a, c, r, t) => { a.SetByIndexLong(t, i => t - 1 - i); randomFraction(a, c, r, t, 0.01); }), new Initializer("reversed, 10% random", (a, c, r, t) => { a.SetByIndexLong(t, i => t - 1 - i); randomFraction(a, c, r, t, 0.1); }), new Initializer("reversed, 30% random", (a, c, r, t) => { a.SetByIndexLong(t, i => t - 1 - i); randomFraction(a, c, r, t, 0.3); }), new Initializer("all equal", (a, c, r, t) => a.Set(t, 0)), }; var sortNames = new Symbol[] { HeapSort, QuickSort, SmoothSort, TimSort }; var sorters = new Sorter[] { new SimpleSorter <int> (HeapSort, SortingExtensions.HeapSortAscending), new SimpleSorter <long> (HeapSort, SortingExtensions.HeapSortAscending), new SimpleSorter <float> (HeapSort, SortingExtensions.HeapSortAscending), new SimpleSorter <double> (HeapSort, SortingExtensions.HeapSortAscending), new FunSorter <V2d> (HeapSort, SortingExtensions.HeapSort), new FunSorter <V3d> (HeapSort, SortingExtensions.HeapSort), new PermSorter <int, int> (HeapSort, SortingExtensions.PermutationHeapSortAscending), new PermSorter <int, long> (HeapSort, SortingExtensions.PermutationHeapSortAscending), new PermSorter <int, float> (HeapSort, SortingExtensions.PermutationHeapSortAscending), new PermSorter <int, double> (HeapSort, SortingExtensions.PermutationHeapSortAscending), new PermFunSorter <int, V2d> (HeapSort, SortingExtensions.PermutationHeapSort), new PermFunSorter <int, V3d> (HeapSort, SortingExtensions.PermutationHeapSort), new PermSorter <long, int> (HeapSort, SortingExtensions.PermutationHeapSortAscending), new PermSorter <long, long> (HeapSort, SortingExtensions.PermutationHeapSortAscending), new PermSorter <long, float> (HeapSort, SortingExtensions.PermutationHeapSortAscending), new PermSorter <long, double> (HeapSort, SortingExtensions.PermutationHeapSortAscending), new PermFunSorter <long, V2d> (HeapSort, SortingExtensions.PermutationHeapSort), new PermFunSorter <long, V3d> (HeapSort, SortingExtensions.PermutationHeapSort), new SimpleSorter <int> (QuickSort, SortingExtensions.QuickSortAscending), new SimpleSorter <long> (QuickSort, SortingExtensions.QuickSortAscending), new SimpleSorter <float> (QuickSort, SortingExtensions.QuickSortAscending), new SimpleSorter <double> (QuickSort, SortingExtensions.QuickSortAscending), new FunSorter <V2d> (QuickSort, SortingExtensions.QuickSort), new FunSorter <V3d> (QuickSort, SortingExtensions.QuickSort), new PermSorter <int, int> (QuickSort, SortingExtensions.PermutationQuickSortAscending), new PermSorter <int, long> (QuickSort, SortingExtensions.PermutationQuickSortAscending), new PermSorter <int, float> (QuickSort, SortingExtensions.PermutationQuickSortAscending), new PermSorter <int, double> (QuickSort, SortingExtensions.PermutationQuickSortAscending), new PermFunSorter <int, V2d> (QuickSort, SortingExtensions.PermutationQuickSort), new PermFunSorter <int, V3d> (QuickSort, SortingExtensions.PermutationQuickSort), new PermSorter <long, int> (QuickSort, SortingExtensions.PermutationQuickSortAscending), new PermSorter <long, long> (QuickSort, SortingExtensions.PermutationQuickSortAscending), new PermSorter <long, float> (QuickSort, SortingExtensions.PermutationQuickSortAscending), new PermSorter <long, double> (QuickSort, SortingExtensions.PermutationQuickSortAscending), new PermFunSorter <long, V2d> (QuickSort, SortingExtensions.PermutationQuickSort), new PermFunSorter <long, V3d> (QuickSort, SortingExtensions.PermutationQuickSort), new SimpleSorter <int> (SmoothSort, SortingExtensions.SmoothSortAscending), new SimpleSorter <long> (SmoothSort, SortingExtensions.SmoothSortAscending), new SimpleSorter <float> (SmoothSort, SortingExtensions.SmoothSortAscending), new SimpleSorter <double> (SmoothSort, SortingExtensions.SmoothSortAscending), new FunSorter <V2d> (SmoothSort, SortingExtensions.SmoothSort), new FunSorter <V3d> (SmoothSort, SortingExtensions.SmoothSort), new PermSorter <int, int> (SmoothSort, SortingExtensions.PermutationSmoothSortAscending), new PermSorter <int, long> (SmoothSort, SortingExtensions.PermutationSmoothSortAscending), new PermSorter <int, float> (SmoothSort, SortingExtensions.PermutationSmoothSortAscending), new PermSorter <int, double> (SmoothSort, SortingExtensions.PermutationSmoothSortAscending), new PermFunSorter <int, V2d> (SmoothSort, SortingExtensions.PermutationSmoothSort), new PermFunSorter <int, V3d> (SmoothSort, SortingExtensions.PermutationSmoothSort), new PermSorter <long, int> (SmoothSort, SortingExtensions.PermutationSmoothSortAscending), new PermSorter <long, long> (SmoothSort, SortingExtensions.PermutationSmoothSortAscending), new PermSorter <long, float> (SmoothSort, SortingExtensions.PermutationSmoothSortAscending), new PermSorter <long, double> (SmoothSort, SortingExtensions.PermutationSmoothSortAscending), new PermFunSorter <long, V2d> (SmoothSort, SortingExtensions.PermutationSmoothSort), new PermFunSorter <long, V3d> (SmoothSort, SortingExtensions.PermutationSmoothSort), new SimpleSorter <int> (TimSort, SortingExtensions.TimSortAscending), new SimpleSorter <long> (TimSort, SortingExtensions.TimSortAscending), new SimpleSorter <float> (TimSort, SortingExtensions.TimSortAscending), new SimpleSorter <double> (TimSort, SortingExtensions.TimSortAscending), new FunSorter <V2d> (TimSort, SortingExtensions.TimSort), new FunSorter <V3d> (TimSort, SortingExtensions.TimSort), new PermSorter <int, int> (TimSort, SortingExtensions.PermutationTimSortAscending), new PermSorter <int, long> (TimSort, SortingExtensions.PermutationTimSortAscending), new PermSorter <int, float> (TimSort, SortingExtensions.PermutationTimSortAscending), new PermSorter <int, double> (TimSort, SortingExtensions.PermutationTimSortAscending), new PermFunSorter <int, V2d> (TimSort, SortingExtensions.PermutationTimSort), new PermFunSorter <int, V3d> (TimSort, SortingExtensions.PermutationTimSort), new PermSorter <long, int> (TimSort, SortingExtensions.PermutationTimSortAscending), new PermSorter <long, long> (TimSort, SortingExtensions.PermutationTimSortAscending), new PermSorter <long, float> (TimSort, SortingExtensions.PermutationTimSortAscending), new PermSorter <long, double> (TimSort, SortingExtensions.PermutationTimSortAscending), new PermFunSorter <long, V2d> (TimSort, SortingExtensions.PermutationTimSort), new PermFunSorter <long, V3d> (TimSort, SortingExtensions.PermutationTimSort), }; var trialCounts = new List <long>(); for (double doubleCount = minimalCount; doubleCount < 0.5 + arrayCount; doubleCount *= countFactor) { trialCounts.Add((long)doubleCount); } var sorterMap = new Dict <(Symbol, Type, Type, bool), Sorter>( from s in sorters select KeyValuePairs.Create((s.Name, s.PermType, s.Type, s.UseCmp), s)); var master = new long[arrayCount]; foreach (var creator in arrayCreators) { var sortArray = creator(arrayCount); var type = sortArray.Type; var permType = sortArray.PermType; var useCmp = sortArray.UseCmp; foreach (var initializer in initializers) { string permText = permType == null ? "" : String.Format("{0} permuted ", permType.Name); string sectionText = String.Format("{0}{1} {2}s", permText, initializer.Name, type.Name); Test.Begin(sectionText); var results = new Tup <long, double> [sortNames.Length, trialCounts.Count]; trialCounts.ForEach((trialCount, tci) => { Test.Begin("array size {0}", trialCount); var trialRepeat = arrayCount / trialCount; var totalCount = trialRepeat * trialCount; initializer.Init(master, trialCount, trialRepeat, totalCount); for (int si = 0; si < sortNames.Length; si++) { for (int i = 0; i < sortNames.Length; i++) { var sni = (si + i) % sortNames.Length; var sorter = sorterMap[(sortNames[sni], permType, type, useCmp)]; sortArray.CopyFrom(master, totalCount); Report.BeginTimed("{0} sorting {1}x {2} {3}s", sorter.Name, trialRepeat, trialCount, type.Name); sortArray.Sort(sorter.SortFunction, trialCount, trialRepeat); var time = Report.End(); results[sni, tci].E0 += totalCount; results[sni, tci].E1 += time; sortArray.Test(Test.IsTrue, trialCount, trialRepeat); } } Test.End(" [{0}x]", sortNames.LongLength * trialRepeat); });