public AssignedEntity() { this.id = new SETImpl <II, Identifier>(typeof(IIImpl)); this.code = new CVImpl(); this.name = new LISTImpl <PN, PersonName>(typeof(PNImpl)); this.responsibleFor = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2007_v02_r02.Pr.Merged.ResponsibleParty>(); this.performance = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2007_v02_r02.Pr.Merged.PrimaryPerformer3>(); this.relatedTo = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2007_v02_r02.Pr.Prpm_mt309000ca.RelatedTo>(); }
public AssignedEntity() { this.id = new SETImpl <II, Identifier>(typeof(IIImpl)); this.code = new CVImpl(); this.name = new LISTImpl <PN, PersonName>(typeof(PNImpl)); this.responsibleForPrivilege = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_02.Pr.Merged.Privilege>(); this.performanceActDefinitionOrEvent = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_02.Pr.Merged.ActDefinitionOrEventName>(); this.relatedToRoleChoice = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_02.Pr.Prpm_mt309000ca.IRoleChoice>(); }
public OtherMedication() { this.id = new SETImpl <II, Identifier>(typeof(IIImpl)); this.code = new CDImpl(); this.statusCode = new CSImpl(); this.effectiveTime = new IVLImpl <TS, Interval <PlatformDate> >(); this.confidentialityCode = new SETImpl <CV, Code>(typeof(CVImpl)); this.routeCode = new CVImpl(); }
public Issues() { this.code = new CVImpl(); this.text = new STImpl(); this.priorityCode = new CVImpl(); this.targetSiteCode = new SETImpl <ST, String>(typeof(STImpl)); this.mitigatedByDetectedIssueManagement = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_02.Common.Merged.IssueManagements_2>(); this.triggerForActRequest = new BLImpl(false); }
public ServiceDeliveryLocation() { this.id = new SETImpl <II, Identifier>(typeof(IIImpl)); this.code = new CVImpl(); this.addr = new LISTImpl <AD, PostalAddress>(typeof(ADImpl)); this.telecom = new LISTImpl <TEL, TelecommunicationAddress>(typeof(TELImpl)); this.effectiveTime = new IVLImpl <TS, Interval <PlatformDate> >(); this.locationName = new STImpl(); }
internal void AddId(string root, string extension) { if (this.id == null) { this.id = new SET <II>(); } this.id.Add(new II(root, extension)); }
public Patient() { this.id = new SETImpl <II, Identifier>(typeof(IIImpl)); this.addr = new ADImpl(); this.telecom = new LISTImpl <TEL, TelecommunicationAddress>(typeof(TELImpl)); this.patientPersonName = new PNImpl(); this.patientPersonAdministrativeGenderCode = new CVImpl(); this.patientPersonBirthTime = new TSImpl(); }
public ReportedReaction() { this.code = new CDImpl(); this.text = new STImpl(); this.effectiveTime = new IVLImpl <TS, Interval <PlatformDate> >(); this.confidentialityCode = new SETImpl <CV, Code>(typeof(CVImpl)); this.value = new CVImpl(); this.subjectOf3CausalityAssessment = new List <Ca.Infoway.Messagebuilder.Model.Ab_mr2007_v02_r02.Iehr.Merged.ReactionAssessments>(); }
public void SETFromIGraphibleCollectionTest() { LIST <IGraphable> stuff = new LIST <IGraphable>( new ST[] { "A", "B", "C", "D" } ); SET <ST> set = new SET <ST>(stuff); Assert.AreEqual(stuff.Count, set.Count); }
public Issues() { this.code = new CVImpl(); this.text = new STImpl(); this.priorityCode = new CVImpl(); this.targetSiteCode = new SETImpl <ST, String>(typeof(STImpl)); this.subjectCausalActs = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_02.Common.Coct_mt260030ca.ICausalActs>(); this.mitigatedByDetectedIssueManagement = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_02.Common.Merged.IssueManagements_2>(); }
public void R2SETSimpleSerializationTest() { SET <INT> inti = SET <INT> .CreateSET(1, 2, 3, 4); string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""><item value=""1""/><item value=""2""/><item value=""3""/><item value=""4""/></test>"; string actualXml = R2SerializationHelper.SerializeAsString(inti); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public Dispense() { this.id = new IIImpl(); this.statusCode = new CSImpl(); this.confidentialityCode = new SETImpl <CV, Code>(typeof(CVImpl)); this.component2AdministrationInstructionsText = new STImpl(); this.subjectOf1DetectedIssueIndicator = new BLImpl(false); this.subjectOf2AnnotationIndicator = new BLImpl(false); }
public void R2SETSimpleParseTest() { SET <INT> inti = SET <INT> .CreateSET(1, 2, 3, 4); string actualXml = R2SerializationHelper.SerializeAsString(inti); SET <INT> int2 = R2SerializationHelper.ParseString <SET <INT> >(actualXml); Assert.AreEqual(inti, int2); }
public DischargeCareSummary() { this.code = new CVImpl(); this.title = new STImpl(); this.confidentialityCode = new SETImpl <CV, Code>(typeof(CVImpl)); this.primaryInformationRecipientRecipients = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_02.Iehr.Merged.IRecipients>(); this.predecessorOldClinicalDocumentEvent = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_02.Iehr.Merged.OldClinicalDocumentEvent>(); this.componentOfPatientCareProvisionEvent = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_02.Common.Coct_mt011001ca.CareCompositions>(); }
public QualifiedEntity() { this.id = new SETImpl <II, Identifier>(typeof(IIImpl)); this.code = new CVImpl(); this.effectiveTime = new IVLImpl <TS, Interval <PlatformDate> >(); this.equivalenceInd = new BLImpl(); this.responsibleForPrivilege = new List <Ca.Infoway.Messagebuilder.Model.Ab_r02_04_03.Pr.Merged.Privilege>(); this.relatedTo = new List <Ca.Infoway.Messagebuilder.Model.Ab_r02_04_03.Pr.Prpm_mt301010ca.RelatedTo>(); }
public AdjudicatedInvoiceElementDetail() { this.id = new SETImpl <II, Identifier>(typeof(IIImpl)); this.code = new CVImpl(); this.unitQuantity = new PQImpl(); this.unitPriceAmt = new RTOImpl <Money, PhysicalQuantity>(); this.netAmt = new MOImpl(); this.factorNumber = new REALImpl(); }
public void SETFromLISTTest() { LIST <ST> stuff = new LIST <ST>( new ST[] { "A", "B", "C", "D" } ); SET <ST> set = (SET <ST>)stuff; Assert.AreEqual(stuff.Count, set.Count); }
public Issues() { this.code = new CVImpl(); this.text = new STImpl(); this.priorityCode = new CVImpl(); this.targetSiteCode = new SETImpl <ST, String>(typeof(STImpl)); this.mitigatedByDetectedIssueManagement = new List <Ca.Infoway.Messagebuilder.Model.Ab_r02_04_03_shr.Common.Coct_mt260022ab.IssueManagements>(); this.triggerForActRequest = new BLImpl(false); }
public OtherMedication() { this.code = new CDImpl(); this.statusCode = new CSImpl(); this.effectiveTime = new IVLImpl <TS, Interval <PlatformDate> >(); this.confidentialityCode = new SETImpl <CV, Code>(typeof(CVImpl)); this.routeCode = new CVImpl(); this.componentDosageInstruction = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_02.Common.Coct_mt270010ca.AdministrationInstructions>(); }
public ReportSectionObservation() { this.id = new IIImpl(); this.code = new CDImpl(); this.text = new STImpl(); this.effectiveTime = new TSImpl(); this.confidentialityCode = new SETImpl <CV, Code>(typeof(CVImpl)); this.value = new ANYImpl <object>(); }
public Location() { this.id = new IIImpl(); this.code = new CVImpl(); this.name = new SETImpl <ST, String>(typeof(STImpl)); this.addr = new ADImpl(); this.statusCode = new CSImpl(); this.subjectOfPosition = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_03.Common.Coct_mt960002ca.GeographicCoordinates>(); }
public ServiceLocation() { this.id = new IIImpl(); this.code = new CVImpl(); this.addr = new ADImpl(); this.telecom = new SETImpl <TEL, TelecommunicationAddress>(typeof(TELImpl)); this.locationName = new STImpl(); this.subjectOfPosition = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_05_00.Common.Coct_mt960002ca.GeographicCoordinates>(); }
public Prescription() { this.id = new IIImpl(); this.statusCode = new CSImpl(); this.confidentialityCode = new SETImpl <CV, Code>(typeof(CVImpl)); this.reason = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_03.Merged.BecauseOf>(); this.preconditionVerificationEventCriterion = new BLImpl(false); this.coverageCoverage = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_04_03.Pharmacy.Merged.CoverageExtensions_1>(); }
/// <summary> /// Example 69 /// Creates a patient structure /// </summary> /// <param name="id">The unique identifier</param> /// <param name="name">The name of the patient</param> /// <param name="addr">The primary address</param> /// <param name="telecom">A primary telecom</param> /// <returns>A constructed patient structure</returns> public Patient CreatePatient( II id, EN name, AD addr, TEL telecom ) { try { // Instantiate the object var retVal = new Patient(); // Populate address retVal.Addr = BAG <AD> .CreateBAG(addr); // Confidentiality Code retVal.ConfidentialityCode = "N"; // Effective Time of the types // High is populated as "Not Applicable" retVal.EffectiveTime = new IVL <TS>( (TS)DateTime.Now, new TS() { NullFlavor = NullFlavor.NotApplicable } ); // Telecom address retVal.Telecom = BAG <TEL> .CreateBAG(telecom); // Populate the ID retVal.Id = SET <II> .CreateSET(id); // Status Code retVal.StatusCode = RoleStatus.Active; // Set entity choice retVal.SetPatientEntityChoiceSubject( new Person() { AdministrativeGenderCode = AdministrativeGender.Male, Name = BAG <EN> .CreateBAG(name), BirthTime = DateTime.Now } ); // cannot return result for unit test purposes return(retVal); } catch { Console.WriteLine("Unit tests must not return a value, but Patient must be returned.."); return(new Patient()); } }
public DocumentSections() { this.code = new CVImpl(); this.title = new STImpl(); this.text = new EDImpl <EncapsulatedData>(); this.statusCode = new CSImpl(); this.confidentialityCode = new SETImpl <CV, Code>(typeof(CVImpl)); this.component1SubSection = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_05_00.Iehr.Repc_mt230001ca.DocumentSections>(); this.component2ReferenceChoice = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_05_00.Iehr.Merged.IReferenceChoice>(); }
/// <summary> /// Create a set of II from a list of DomainIdentifier /// </summary> public SET <II> CreateIISet(List <DomainIdentifier> identifiers, List <IResultDetail> dtls) { SET <II> retVal = new SET <II>(identifiers.Count, II.Comparator); foreach (var id in identifiers) { retVal.Add(CreateII(id, dtls)); } return(retVal); }
public ActiveMedication() { this.moodCode = new CSImpl(); this.id = new IIImpl(); this.code = new CDImpl(); this.statusCode = new CSImpl(); this.effectiveTime = new IVLImpl <TS, Interval <PlatformDate> >(); this.confidentialityCode = new SETImpl <CV, Code>(typeof(CVImpl)); this.doseQuantity = new PQImpl(); }
public DrugPrescriptionDetailQueryParameters() { this.careCompositionIDValue = new List <II>(); this.careCompositionTypeValue = new List <CV>(); this.includeEventHistoryIndicatorValue = new BLImpl(); this.includeIssuesIndicatorValue = new BLImpl(); this.includeNotesIndicatorValue = new BLImpl(); this.includePendingChangesIndicatorValue = new BLImpl(); this.prescriptionOrderNumberValue = new SETImpl <II, Identifier>(typeof(IIImpl)); }
public BillableClinicalService() { this.id = new IIImpl(); this.code = new CVImpl(); this.effectiveTime = new IVLImpl <TS, Interval <PlatformDate> >(); this.reasonCode = new SETImpl <CV, Code>(typeof(CVImpl)); this.productManufacturedProduct = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_05_00.Common.Merged.ManufacturedProduct>(); this.pertinentInformation1 = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_05_00.Common.Coct_mt290000ca.AccidentInformation>(); this.pertinentInformation3 = new List <Ca.Infoway.Messagebuilder.Model.Pcs_mr2009_r02_05_00.Common.Merged.DiagnosisInformation>(); }
public HealthcareProvider() { this.id = new SETImpl <II, Identifier>(typeof(IIImpl)); this.code = new CVImpl(); this.healthCareProviderPersonName = new PNImpl(); this.healthCareProviderPersonTelecom = new TELImpl(); this.healthCareProviderPersonAdministrativeGenderCode = new CVImpl(); this.healthCareProviderPersonBirthTime = new TSImpl(); this.healthCareProviderPersonAddr = new ADImpl(); }
/// <summary> /// Returns a random simple bipartite graph on <tt>V1</tt> and <tt>V2</tt> vertices /// with <tt>E</tt> edges. /// </summary> /// <param name="v1">V1 the number of vertices in one partition</param> /// <param name="v2">V2 the number of vertices in the other partition</param> /// <param name="e">E the number of edges</param> /// <returns>a random simple bipartite graph on <tt>V1</tt> and <tt>V2</tt> vertices, containing a total of <tt>E</tt> edges</returns> /// <exception cref="ArgumentException">if no such simple bipartite graph exists</exception> public static Graph Bipartite(int v1, int v2, int e) { if (e > (long)v1 * v2) throw new ArgumentException("Too many edges"); if (e < 0) throw new ArgumentException("Too few edges"); var g = new Graph(v1 + v2); var vertices = new int[v1 + v2]; for (var i = 0; i < v1 + v2; i++) vertices[i] = i; StdRandom.Shuffle(vertices); var set = new SET<EdgeU>(); while (g.E < e) { var i = StdRandom.Uniform(v1); var j = v1 + StdRandom.Uniform(v2); var edge = new EdgeU(vertices[i], vertices[j]); if (set.Contains(edge)) continue; set.Add(edge); g.AddEdge(vertices[i], vertices[j]); } return g; }
/// <summary> /// Returns a random simple DAG containing <tt>V</tt> vertices and <tt>E</tt> edges. /// Note: it is not uniformly selected at random among all such DAGs. /// </summary> /// <param name="v">V the number of vertices</param> /// <param name="e">E the number of vertices</param> /// <returns>a random simple DAG on <tt>V</tt> vertices, containing a total of <tt>E</tt> edges</returns> /// <exception cref="ArgumentException">if no such simple DAG exists</exception> public static Digraph Dag(int v, int e) { if (e > (long)v * (v - 1) / 2) throw new ArgumentException("Too many edges"); if (e < 0) throw new ArgumentException("Too few edges"); var g = new Digraph(v); var set = new SET<EdgeD>(); var vertices = new int[v]; for (var i = 0; i < v; i++) vertices[i] = i; StdRandom.Shuffle(vertices); while (g.E < e) { var ve = StdRandom.Uniform(v); var we = StdRandom.Uniform(v); var edge = new EdgeD(ve, we); if ((ve < we) && !set.Contains(edge)) { set.Add(edge); g.AddEdge(vertices[ve], vertices[we]); } } return g; }
internal void AddId(Guid id) { if (this.id == null) { this.id = new SET<II>(); } this.id.Add(new II(id)); }
internal void AddId(string root, string extension) { if (this.id == null) { this.id = new SET<II>(); } this.id.Add(new II(root, extension)); }
public void IVLIsSemanticEqualsTest() { SET<INT> ints = new SET<INT>() { 1, 2, 4, 6 }; IVL<INT> range = new IVL<INT>(0, 7); }
/// <summary> /// Parse the PQ back into a structure /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result) { // Create the base formatter PDVFormatter baseFormatter = new PDVFormatter(); baseFormatter.Host = this.Host; // Read temporary values string tUnit = null; if(s.GetAttribute("unit") != null) tUnit = s.GetAttribute("unit"); SET<CodingRationale> tRationale = null; if (s.GetAttribute("codingRationale") != null) tRationale = Util.Convert<SET<CodingRationale>>(s.GetAttribute("codingRationale")); // Parse PDV content (only attributes) var retVal = baseFormatter.ParseAttributes<PQ>(s, result); // Set PDV content retVal.Unit = tUnit; retVal.CodingRationale = tRationale; // Process elements // This requires a QTY formatter as QTY elements may be // in the stream as well #region Elements if (!s.IsEmptyElement) { // Prepare a formatter to process QTY elements QTYFormatter qtyFormatter = new QTYFormatter(); qtyFormatter.Host = this.Host; // Exit markers int sDepth = s.Depth; string sName = s.Name; // Translations SET<PQR> translations = new SET<PQR>(); // Read the next element s.Read(); // Read until exit condition is fulfilled while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { if (s.LocalName == "translation") // Format using ED { var hostResult = Host.Parse(s, typeof(PQR)); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); translations.Add(hostResult.Structure as PQR); } else qtyFormatter.ParseElementsInline(s, retVal, result); } catch (MessageValidationException e) { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, s.ToString(), e)); } finally { if (s.Name == oldName) s.Read(); } } // Set translations if (!translations.IsEmpty) retVal.Translation = translations; } #endregion // Validate ANYFormatter anyFormatter = new ANYFormatter(); string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; anyFormatter.Validate(retVal as ANY, pathName, result); // REturn instance return retVal; }
internal void SetId(string root, string extension, string assignedAuthorityName) { this.id = new SET<II>(); II temp = new II(); temp.Extension = extension; temp.Root = root; temp.AssigningAuthorityName = assignedAuthorityName; this.id.Add(temp); }
public void SETContentDifferentEqualityTest() { SET<ST> a = new SET<ST>(new ST[] { "A", "B", "C" }), b = new SET<ST>(new ST[] { "A", "B", "D", "E" }); Assert.IsFalse(a.Equals(b)); }
public void SETTypeMismatchEqualityTest() { SET<ST> a = new SET<ST>(new ST[] { "A", "B", "C" }), b = new SET<ST>(new ST[] { "D", "E" }); Assert.IsFalse(a.Equals("A B C")); }
public void AddingDupesToSetTest01() { // Create the SET SET<INT> ints = new SET<INT>(); // Add numbers 0 through 9 for (var i = 0; i <= 9; i++) { ints.Add(i); } try { ints.Add(5); // 5 already exists in the set. Exception is thrown } catch (DuplicateItemException e) { Console.WriteLine("Cannot add duplicate item."); } ints.NullFlavor = null; Assert.IsTrue(ints.Validate()); }
public void AddingDupesToSetTest04() { // Create the SET SET<INT> ints = new SET<INT>(); ints.NullFlavor = null; Assert.IsFalse(ints.Validate()); }
public void AddingDupesToSetTest03() { // Create the SET SET<INT> ints = new SET<INT>(); ints.NullFlavor = NullFlavor.Other; Assert.IsTrue(ints.Validate()); }
/// <summary> /// Returns a random rooted-out DAG on <tt>V</tt> vertices and <tt>E</tt> edges. /// A rooted out-tree is a DAG in which every vertex is reachable from a /// single vertex. /// The DAG returned is not chosen uniformly at random among all such DAGs. /// </summary> /// <param name="v">V the number of vertices</param> /// <param name="e">E the number of edges</param> /// <returns>a random rooted-out DAG on <tt>V</tt> vertices and <tt>E</tt> edges</returns> public static Digraph RootedOutDag(int v, int e) { if (e > (long)v * (v - 1) / 2) throw new ArgumentException("Too many edges"); if (e < v - 1) throw new ArgumentException("Too few edges"); var g = new Digraph(v); var set = new SET<EdgeD>(); // fix a topological order var vertices = new int[v]; for (var i = 0; i < v; i++) vertices[i] = i; StdRandom.Shuffle(vertices); // one edge pointing from each vertex, other than the root = vertices[V-1] for (var ve = 0; ve < v - 1; ve++) { var we = StdRandom.Uniform(ve + 1, v); var edge = new EdgeD(we, ve); set.Add(edge); g.AddEdge(vertices[we], vertices[ve]); } while (g.E < e) { var ve = StdRandom.Uniform(v); var we = StdRandom.Uniform(v); var edge = new EdgeD(we, ve); if ((ve < we) && !set.Contains(edge)) { set.Add(edge); g.AddEdge(vertices[we], vertices[ve]); } } return g; }
public DeDup(IEnumerable<string> a) { _set = new SET<string>(); ; InsertWords(a); }
/// <summary> /// Returns a random simple digraph containing <tt>V</tt> vertices and <tt>E</tt> edges. /// </summary> /// <param name="v">V the number of vertices</param> /// <param name="e">E the number of vertices</param> /// <returns>a random simple digraph on <tt>V</tt> vertices, containing a total of <tt>E</tt> edges</returns> /// <exception cref="ArgumentException">if no such simple digraph exists</exception> public static Digraph Simple(int v, int e) { if (e > (long)v * (v - 1)) throw new ArgumentException("Too many edges"); if (e < 0) throw new ArgumentException("Too few edges"); var g = new Digraph(v); var set = new SET<EdgeD>(); while (g.E < e) { var ve = StdRandom.Uniform(v); var we = StdRandom.Uniform(v); var edge = new EdgeD(ve, we); if ((ve != we) && !set.Contains(edge)) { set.Add(edge); g.AddEdge(ve, we); } } return g; }
public void SETFromIGraphibleCollectionTest() { LIST<IGraphable> stuff = new LIST<IGraphable>( new ST[] { "A", "B", "C", "D" } ); SET<ST> set = new SET<ST>(stuff); Assert.AreEqual(stuff.Count, set.Count); }
/// <summary> /// Returns a random simple digraph on <tt>V</tt> vertices, <tt>E</tt> /// edges and (at least) <tt>c</tt> strong components. The vertices are randomly /// assigned integer labels between <tt>0</tt> and <tt>c-1</tt> (corresponding to /// strong components). Then, a strong component is creates among the vertices /// with the same label. Next, random edges (either between two vertices with /// the same labels or from a vetex with a smaller label to a vertex with a /// larger label). The number of components will be equal to the number of /// distinct labels that are assigned to vertices. /// </summary> /// <param name="v">V the number of vertices</param> /// <param name="e">E the number of edges</param> /// <param name="c">c the (maximum) number of strong components</param> /// <returns>a random simple digraph on <tt>V</tt> vertices and <tt>E</tt> edges, with (at most) <tt>c</tt> strong components</returns> /// <exception cref="ArgumentException">if <tt>c</tt> is larger than <tt>V</tt></exception> public static Digraph Strong(int v, int e, int c) { if (c >= v || c <= 0) throw new ArgumentException("Number of components must be between 1 and V"); if (e <= 2 * (v - c)) throw new ArgumentException("Number of edges must be at least 2(V-c)"); if (e > (long)v * (v - 1) / 2) throw new ArgumentException("Too many edges"); // the digraph var g = new Digraph(v); // edges added to G (to avoid duplicate edges) var set = new SET<EdgeD>(); var label = new int[v]; for (var i = 0; i < v; i++) label[i] = StdRandom.Uniform(c); // make all vertices with label c a strong component by // combining a rooted in-tree and a rooted out-tree for (var i = 0; i < c; i++) { // how many vertices in component c var count = 0; for (var ii = 0; ii < g.V; ii++) { if (label[ii] == i) count++; } // if (count == 0) System.err.println("less than desired number of strong components"); var vertices = new int[count]; var j = 0; for (var jj = 0; jj < v; jj++) { if (label[jj] == i) vertices[j++] = jj; } StdRandom.Shuffle(vertices); // rooted-in tree with root = vertices[count-1] for (var ve = 0; ve < count - 1; ve++) { var we = StdRandom.Uniform(ve + 1, count); var edge = new EdgeD(we, ve); set.Add(edge); g.AddEdge(vertices[we], vertices[ve]); } // rooted-out tree with root = vertices[count-1] for (var ve = 0; ve < count - 1; ve++) { var we = StdRandom.Uniform(ve + 1, count); var edge = new EdgeD(ve, we); set.Add(edge); g.AddEdge(vertices[ve], vertices[we]); } } while (g.E < e) { var ve = StdRandom.Uniform(v); var we = StdRandom.Uniform(v); var edge = new EdgeD(ve, we); if (!set.Contains(edge) && ve != we && label[ve] <= label[we]) { set.Add(edge); g.AddEdge(ve, we); } } return g; }
public void SETUnionItemTest() { SET<ST> a = new SET<ST>(new ST[] { "A", "B", "C" }); Assert.AreEqual(4, a.Union((ST)"D").Count); }
public void SETContentSameEqualityTest() { SET<ST> a = new SET<ST>(new ST[] { "A", "B", "C" }), b = new SET<ST>(new ST[] { "A", "B", "C" }); Assert.IsTrue(a.Equals(b)); }
public void SETIntersectionSETTest() { SET<ST> a = new SET<ST>(new ST[] { "A", "B", "C" }), b = new SET<ST>(new ST[] { "B", "C", "D", "E" }); Assert.AreEqual(2, a.Intersection(b).Count); }
public void SETUnionSETTest() { SET<ST> a = new SET<ST>(new ST[] { "A", "B", "C" }), b = new SET<ST>(new ST[] { "D", "E" }); Assert.AreEqual(5, a.Union(b).Count); }
public void CustomCompTest01() { // Create a custom comparator using an anonymous delegate SET<II> identifiers = new SET<II>(); identifiers.Comparator = delegate(II a, II b) { return a == b || a.Equals(b) ? 0 : 1; }; // Create custom comparator using lambda identifiers.Comparator = (a, b) => a == b || a.Equals(b) ? 0 : 1; // the instance identifiers in these sets cannot match identifiers.NullFlavor = NullFlavor.NoInformation; Assert.IsTrue(identifiers.Validate()); }
public void SETExceptSETTest() { SET<ST> a = new SET<ST>(new ST[] { "A", "B", "C" }), b = new SET<ST>(new ST[] { "B", "C", "D", "E" }); Assert.AreEqual(1, a.Except(b).Count); }
/// <summary> /// Returns a random simple graph containing <tt>V</tt> vertices and <tt>E</tt> edges. /// </summary> /// <param name="v">V the number of vertices</param> /// <param name="e">E the number of edges</param> /// <returns> random simple graph on <tt>V</tt> vertices, containing a total of <tt>E</tt> edges</returns> /// <exception cref="ArgumentException">if no such simple graph exists</exception> public static Graph Simple(int v, int e) { if (e > (long)v * (v - 1) / 2) throw new ArgumentException("Too many edges"); if (e < 0) throw new ArgumentException("Too few edges"); var g = new Graph(v); var set = new SET<EdgeU>(); while (g.E < e) { var ve = StdRandom.Uniform(v); var we = StdRandom.Uniform(v); var edge = new EdgeU(ve, we); if ((ve == we) || set.Contains(edge)) continue; set.Add(edge); g.AddEdge(ve, we); } return g; }
public void SETLinqTest2() { SET<ST> test = new SET<ST>(new ST[]{ "Bob", "Matt", "Corey", "Jasper", "Trevor", "Justin", "Mike", "Brian", "Mark", "Duane", "Charley"}, (a, b) => a.Value.CompareTo(b.Value)); var names = from name in test where name.Value.StartsWith("M") select name; Assert.AreNotEqual(names.Count(), 2); }
public void SETExceptionOps01() { // Create a set of all integers from 0 to 9 SET<INT> ints= new SET<INT>(10); for (var i = 0; i <= 9; i++ ) { ints.Add(i); } // Get a set of even numbers SET<INT> evens = SET<INT>.CreateSET(2, 4, 6, 8); // Get a resultant set SET<INT> results = ints.Except(evens); foreach (var i in results) { Console.Write(i); } results.NullFlavor = null; Assert.IsTrue(results.Validate()); }
internal void SetId(Guid id) { this.id = new SET<II>(); this.id.Add(new II(id)); }
internal void SetId(string root, string extension) { this.id = new SET<II>(); this.id.Add(new II(root, extension)); }
public void Run() { Console.WriteLine("Choose file:"); // Prompt Console.WriteLine("1 - tinySET.txt"); // Prompt Console.WriteLine("or quit"); // Prompt var fileNumber = Console.ReadLine(); var fieName = string.Empty; switch (fileNumber) { case "1": fieName = "tinySET.txt"; break; case "quit": return; default: return; } var @in = new In($"Files\\Searching\\{fieName}"); var keys = @in.ReadAllLines(); //var list = words.Select(word => new StringComparable(word)).ToList(); //var listComparable = list.Cast<IComparable>().ToList(); //var arrayComparable = list.Cast<IComparable>().ToArray(); //var listStrings = words.ToList(); var set = new SET<string>(); foreach (var key in keys) { set.Add(key); } // print results foreach (var item in set) { Console.WriteLine(item); } Console.WriteLine("-----------------------------------------------------------"); Console.WriteLine(set.Contains("www.cs.princeton.edu")); Console.WriteLine(!set.Contains("www.harvardsucks.com")); Console.WriteLine(set.Contains("www.simpsons.com")); Console.WriteLine("-----------------------------------------------------------"); Console.WriteLine(); Console.WriteLine("-----------------------------------------------------------"); Console.WriteLine("ceiling(www.simpsonr.com) = " + set.Ceiling("www.simpsonr.com")); Console.WriteLine("ceiling(www.simpsons.com) = " + set.Ceiling("www.simpsons.com")); Console.WriteLine("ceiling(www.simpsont.com) = " + set.Ceiling("www.simpsont.com")); Console.WriteLine("floor(www.simpsonr.com) = " + set.Floor("www.simpsonr.com")); Console.WriteLine("floor(www.simpsons.com) = " + set.Floor("www.simpsons.com")); Console.WriteLine("floor(www.simpsont.com) = " + set.Floor("www.simpsont.com")); Console.WriteLine("-----------------------------------------------------------"); Console.WriteLine(); Console.WriteLine("-----------------------------------------------------------"); Console.WriteLine(set.Max()); Console.WriteLine(set.Min()); Console.WriteLine(); Console.ReadLine(); }
/// <summary> /// Graph <paramref name="o"/> onto <paramref name="s"/> /// </summary> public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result) { // XP is special, it does not extend anything so we have to graph from scratch var instance = o as ENXP; // Null flavor? if (instance.NullFlavor != null) s.WriteAttributeString("nullFlavor", Util.ToWireFormat(instance.NullFlavor)); else { // Validate DatatypeR2FormatterParseResult tResult = new DatatypeR2FormatterParseResult(result.ValidateConformance); new ANYFormatter().Validate(instance, s.ToString(), tResult); result.AddResultDetail(tResult.Details); // Qualifiers (copy for modification) SET<CS<EntityNamePartQualifier>> qualifiers = new SET<CS<EntityNamePartQualifier>>(); if(instance.Qualifier != null) foreach (var qlf in instance.Qualifier) qualifiers.Add(qlf.Clone() as CS<EntityNamePartQualifier>); // Unsupported properties if (instance.ControlActExt != null) result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "ControlActExt", "ENXP", s.ToString())); if (instance.ControlActRoot != null) result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "ControlActRoot", "ENXP", s.ToString())); if (instance.ValidTimeHigh != null) result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "ValidTimeHigh", "ENXP", s.ToString())); if (instance.ValidTimeLow != null) result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "ValidTimeLow", "ENXP", s.ToString())); if (instance.Flavor != null) result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "Flavor", "ENXP", s.ToString())); if (instance.UpdateMode != null) result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "UpdateMode", "ENXP", s.ToString())); // Output the supported properties if (instance.Value != null) s.WriteAttributeString("value", instance.Value); if (instance.Code != null) s.WriteAttributeString("code", instance.Code); if (instance.CodeSystem != null) s.WriteAttributeString("codeSystem", instance.CodeSystem); if (instance.CodeSystemVersion != null) s.WriteAttributeString("codeSystemVersion", instance.CodeSystemVersion); if (instance.Type != null) { // Qualifiers that count as TITLE EntityNamePartQualifier[] titleQualifiers = new EntityNamePartQualifier[] { EntityNamePartQualifier.Professional, EntityNamePartQualifier.Nobility, EntityNamePartQualifier.Academic , EntityNamePartQualifier.LegalStatus }; // If type is not SFX or PFX then output the type, // if it is either SFX or PFX then don't output the type // but do modify the qualifier switch(instance.Type.Value) { case EntityNamePartType.Prefix: if (instance.Qualifier == null) instance.Qualifier = new SET<CS<EntityNamePartQualifier>>(); if(!qualifiers.Contains(EntityNamePartQualifier.Prefix)) qualifiers.Add(EntityNamePartQualifier.Prefix); // Change the instance type if(Array.Exists(titleQualifiers, q => qualifiers.Contains(q))) s.WriteAttributeString("type", "TITLE"); break; case EntityNamePartType.Suffix: if (instance.Qualifier == null) instance.Qualifier = new SET<CS<EntityNamePartQualifier>>(); if (!qualifiers.Contains(EntityNamePartQualifier.Suffix)) qualifiers.Add(EntityNamePartQualifier.Suffix); // Change the instance type if (Array.Exists(titleQualifiers, q => qualifiers.Contains(q))) s.WriteAttributeString("type", "TITLE"); break; default: s.WriteAttributeString("type", Util.ToWireFormat(instance.Type)); break; } } if (!qualifiers.IsEmpty) s.WriteAttributeString("qualifier", Util.ToWireFormat(qualifiers)); } }