Ejemplo n.º 1
0
        // static factory method, which consults registry to avoid multiple instantiations
        public static IBlauSpace create(int dimension, string [] names, double [] min, double [] max)
        {
            BlauSpace s = new BlauSpace(dimension, names, min, max);

            // register new instances with the registry
            BlauSpaceRegistry.Instance().add(s);
            // query the registry for canonical representative
            IBlauSpace s_validated = BlauSpaceRegistry.Instance().validate(s);

            return(s_validated);
        }
Ejemplo n.º 2
0
        // blauspace comparator specific
        public int CompareTo(BlauSpace bs)
        {
            int c1 = (this.Dimension < bs.Dimension) ? -1 : ((this.Dimension == bs.Dimension) ? 0 : +1);

            if (c1 != 0)
            {
                return(c1);
            }

            BlauSpaceAxisComparer cmp = new BlauSpaceAxisComparer();

            if (_indexedAxes == null)
            {
                throw new ArgumentException("_indexedAxes is null");
            }
            if (bs._indexedAxes == null)
            {
                throw new ArgumentException("bs._indexedAxes is null");
            }

            SortedDictionary <BlauSpaceAxis, BlauSpaceAxis> thisAxes = new SortedDictionary <BlauSpaceAxis, BlauSpaceAxis>(cmp);

            foreach (int x in _indexedAxes.Keys)
            {
                thisAxes.Add((BlauSpaceAxis)_indexedAxes[x], (BlauSpaceAxis)_indexedAxes[x]);
            }
            SortedDictionary <BlauSpaceAxis, BlauSpaceAxis> bsAxes = new SortedDictionary <BlauSpaceAxis, BlauSpaceAxis>(cmp);

            foreach (int x in bs._indexedAxes.Keys)
            {
                bsAxes.Add((BlauSpaceAxis)bs._indexedAxes[x], (BlauSpaceAxis)bs._indexedAxes[x]);
            }

            IEnumerator <BlauSpaceAxis> thisAxesEnum = thisAxes.Keys.GetEnumerator();
            IEnumerator <BlauSpaceAxis> bsAxesEnum   = bsAxes.Keys.GetEnumerator();

            while (thisAxesEnum.MoveNext())
            {
                BlauSpaceAxis x1 = thisAxesEnum.Current;

                bsAxesEnum.MoveNext();
                BlauSpaceAxis x2 = bsAxesEnum.Current;
                int           c2 = cmp.Compare(x1, x2);
                if (c2 != 0)
                {
                    return(c2);
                }
            }
            return(0);
        }
Ejemplo n.º 3
0
        // blauspace comparator generic
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            BlauSpace bs = obj as BlauSpace;

            if (bs != null)
            {
                return(this.CompareTo(bs));
            }
            else
            {
                throw new ArgumentException("Object is not a BlauSpace");
            }
        }