Exemplo n.º 1
0
        /// <summary>
        /// Parse a SET of T from the string <paramref name="s"/>
        /// </summary>
        /// <param name="s">The string to parse</param>
        /// <returns>The parsed set</returns>
        internal static SET <T> FromString(string s)
        {
            string[] values = s.Split(' ');
            SET <T>  retVal = new SET <T>((Comparison <T>)((a, b) => a.Equals(b) ? 0 : -1));

            foreach (string value in values)
            {
                retVal.Add((T)Util.FromWireFormat(value, typeof(T)));
            }
            return(retVal);
        }
Exemplo n.º 2
0
        public SET <T> Intersection(SET <T> otherset)
        {
            SET <T> retVal = new SET <T>(this.Comparator);

            foreach (T item in this)
            {
                if (otherset.Contains(item))
                {
                    retVal.Add(item);
                }
            }
            return(retVal);
        }
Exemplo n.º 3
0
        internal static SET <T> Parse(LIST <IGraphable> o)
        {
            SET <T> retVal = new SET <T>(o);

            retVal.NullFlavor     = o.NullFlavor;
            retVal.ControlActExt  = o.ControlActExt;
            retVal.ControlActRoot = o.ControlActRoot;
            retVal.Flavor         = o.Flavor;
            retVal.UpdateMode     = o.UpdateMode;
            retVal.ValidTimeHigh  = o.ValidTimeHigh;
            retVal.ValidTimeLow   = o.ValidTimeLow;
            return(retVal);
        }
Exemplo n.º 4
0
        public SET <T> Except(SET <T> otherset)
        {
            SET <T> retVal = new SET <T>();

            foreach (T item in this)
            {
                if (!otherset.Contains(item))
                {
                    retVal.Add(item);
                }
            }
            return(retVal);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Return a new DSET with all the contents of this DSET except the element specified
        /// </summary>
        public SET <T> Except(T element)
        {
            SET <T> retVal = new SET <T>();

            foreach (T item in this)
            {
                if (Comparator(item, element) != 0)
                {
                    retVal.Add(item);
                }
            }
            return(retVal);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Determine if this SET of T equals another SET of T
 /// </summary>
 /// <remarks>
 /// This equality method differs from the <see cref="T:MARC.Everest.DataTypes.BAG{T}"/> and <see cref="T:MARC.Everest.DataTypes.LIST{T}"/>
 /// in that it not only compares the contents of each set to ensure that all data is present in both sets, it uses the comparator of
 /// this set to determine if the "item" is the same (rather than the equality method)
 /// </remarks>
 public bool Equals(SET <T> other)
 {
     if (other != null)
     {
         bool result = base.Equals((ANY)other) &&
                       other.Count == this.Count;
         for (int i = 0; i < (result ? items.Count : 0); i++)
         {
             result &= Items[i].Equals(other.Items[i]);
         }
         return(result);
     }
     return(false);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Create a union of this set and another set
        /// </summary>
        public SET <T> Union(T element)
        {
            SET <T> retVal = new SET <T>();

            foreach (T item in this)
            {
                retVal.Add(item);
            }
            if (!retVal.Contains(element))
            {
                retVal.Add(element);
            }
            return(retVal);
        }
Exemplo n.º 8
0
        public SET <T> Union(SET <T> otherset)
        {
            SET <T> retVal = new SET <T>();

            foreach (T item in this)
            {
                retVal.Add(item);
            }
            foreach (T item in otherset)
            {
                if (!retVal.Contains(item))
                {
                    retVal.Add(item);
                }
            }
            return(retVal);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a set from a bound IVL
        /// </summary>
        /// <remarks>This function will call <see cref="F:FillInDetails"/> prior to construction of the set as it
        /// needs to ensure that low and high bounds are known</remarks>
        /// <exception cref="T:System.InvalidOperationException">When <typeparamref name="T"/> does not implement <see cref="T:MARC.Everest.DataTypes.Interfaces.IOrderedDataType{T}"/></exception>
        public SET <T> ToSet()
        {
            var lh = this.ToBoundIVL();

            if (lh.Low is IOrderedDataType <T> && lh.Low is IComparable <T> )
            {
                SET <T> retVal  = new SET <T>(10);
                var     current = lh.Low as IOrderedDataType <T>;
                while ((current as IComparable <T>).CompareTo(lh.High) <= (lh.HighClosed == true ? 0 : -1))
                {
                    retVal.Add((T)current);
                    current = current.NextValue() as IOrderedDataType <T>;
                }
                return(retVal);
            }
            else
            {
                throw new InvalidOperationException(String.Format(EverestFrameworkContext.CurrentCulture, "Cannot enumerate '{0}' to construct the resultant set", typeof(T).FullName));
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Determine if this IVL when represented as a <see cref="T:SET{T}"/>
 /// is semantically equivalent to <paramref name="set"/>
 /// </summary>
 private BL SemanticEqualsInternal(SET <T> set)
 {
     return(this.ToSet().SemanticEquals(set));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Creates an organization name
 /// </summary>
 public static ON CreateON(SET <CS <EntityNameUse> > use, params ENXP[] parts)
 {
     return(new ON(use, parts));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Create a new entity named instance using the specified values
 /// </summary>
 /// <param name="parts">The parts of the names</param>
 /// <param name="use">The uses of this name</param>
 public ON(SET <CS <EntityNameUse> > use, IEnumerable <ENXP> parts)
     : base(use, parts)
 {
 }
Exemplo n.º 13
0
 /// <summary>
 /// Determine if this IVL when represented as a <see cref="T:SET{T}"/>
 /// is semantically equivalent to <paramref name="set"/>
 /// </summary>
 private BL SemanticEqualsInternal(SET <T> set)
 {
     // Check if each of the set members are in this IVL
     return(this.ToSet().SemanticEquals(set));
 }
Exemplo n.º 14
0
 public CE(T code, string codeSystem, IEnumerable <CD <T> > translation) : base(code, codeSystem)
 {
     Translation = new SET <CD <T> >(translation, CD <T> .Comparator);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Helper method for creating AD instances
 /// </summary>
 /// <param name="use">The use of the returned address</param>
 /// <param name="parts">The parts that make up the address</param>
 public static AD CreateAD(SET <PostalAddressUse> use, params ADXP[] parts)
 {
     return(new AD(new SET <CS <PostalAddressUse> >(use), parts));
 }
Exemplo n.º 16
0
 public AD(SET <CS <PostalAddressUse> > use, IEnumerable <ADXP> parts)
     : this(parts)
 {
     Use = use;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Create a new entity named instance using the specified values
 /// </summary>
 /// <param name="parts">The parts of the names</param>
 /// <param name="use">The uses of this name</param>
 public EN(SET <CS <EntityNameUse> > use, IEnumerable <ENXP> parts) : this()
 {
     Part = new List <ENXP>(parts); this.Use = use;
 }