コード例 #1
0
ファイル: TreeSet.cs プロジェクト: zhouweiaccp/XobotOS
 /// <summary>
 /// Returns a new
 /// <code>TreeSet</code>
 /// with the same elements, size and comparator
 /// as this
 /// <code>TreeSet</code>
 /// .
 /// </summary>
 /// <returns>
 /// a shallow copy of this
 /// <code>TreeSet</code>
 /// .
 /// </returns>
 /// <seealso cref="System.ICloneable">System.ICloneable</seealso>
 public virtual object clone()
 {
     java.util.TreeSet <E> clone_1 = (java.util.TreeSet <E>)base.MemberwiseClone();
     if (backingMap is java.util.TreeMap <E, object> )
     {
         clone_1.backingMap = (java.util.NavigableMap <E, object>)((java.util.TreeMap <E, object
                                                                                       >)backingMap).clone();
     }
     else
     {
         clone_1.backingMap = new java.util.TreeMap <E, object>(backingMap);
     }
     return(clone_1);
 }
コード例 #2
0
ファイル: IsEmpty.cs プロジェクト: viceice/sharpen
 public virtual void test()
 {
     System.Collections.Generic.List <string> list = new System.Collections.Generic.List
                                                     <string>();
     System.Collections.Generic.ICollection <string> collection = list;
     System.Collections.Generic.HashSet <int>        hashSet    = new System.Collections.Generic.HashSet
                                                                  <int>();
     java.util.TreeSet <int> treeSet = new java.util.TreeSet <int>();
     System.Collections.Generic.HashSet <int>            set     = hashSet;
     System.Collections.Generic.Dictionary <int, string> hashMap = new System.Collections.Generic.Dictionary
                                                                   <int, string>();
     System.Collections.Generic.SortedDictionary <int, string> treeMap = new System.Collections.Generic.SortedDictionary
                                                                         <int, string>();
     System.Collections.Generic.IDictionary <int, string> map = hashMap;
     (list.Count == 0);
     (collection.Count == 0);
     (hashSet.Count == 0);
     (treeSet.Count == 0);
     (set.Count == 0);
     (hashMap.Count == 0);
     (treeMap.Count == 0);
     (map.Count == 0);
 }
コード例 #3
0
ファイル: Header.cs プロジェクト: bastie/NetVampire
        /**
         * Create a header structure from an input stream. <p/> The header
         * structure of a signature or a header can be read and also the index
         * entries containing the tags for this rpm section (signature or
         * header). <p/> Unless we have a raw header from headerUnload or the
         * database, a header is read consisting of the following fields:
         * <code><pre>
         * byte magic[3];      (3  byte)  (8e ad e8)
         * int version;        (1  byte)
         * byte reserved[4];   (4  byte)
         * long num_index;     (4  byte)
         * long num_data;      (4  byte)
         * </pre></code> <p/> Afterwards the index entries are read and then the tags
         * and the correspondig data entries are read.
         *
         * @param inputStream
         *                An inputstream containing rpm file informations
         * @param rawHeader
         *                Are we a raw header (from headerUnload or rpmdb)
         * @throws IOException
         *                 if an error occurs on reading informations out of the
         *                 stream
         */
        public Header(java.io.DataInputStream inputStream, bool rawHeader, Store store)
        {//throws IOException {
            this.store = store;

            if (logger.isLoggable(java.util.logging.Level.FINER))
            {
                logger.finer("Start Reading Header");
            }

            if (!rawHeader)
            {
                // Read header
                size = HEADER_LENGTH;

                int magic = 0;

                do
                {
                    magic = inputStream.readUnsignedByte();
                    if (magic == 0)
                    {
                        inputStream.skip(7);
                    }
                } while (magic == 0);

                check(magic == 0x8E, "Header magic 0x" + java.lang.Integer.toHexString(magic)
                      + " != 0x8E");
                magic = inputStream.readUnsignedByte();
                check(magic == 0xAD, "Header magic 0x" + java.lang.Integer.toHexString(magic)
                      + " != 0xAD");
                magic = inputStream.readUnsignedByte();
                check(magic == 0xE8, "Header magic 0x" + java.lang.Integer.toHexString(magic)
                      + " != 0xE8");
                version = inputStream.readUnsignedByte();

                if (logger.isLoggable(java.util.logging.Level.FINER))
                {
                    logger.finer("version: " + version);
                }

                // skip reserved bytes
                inputStream.skipBytes(4);
            }

            indexNumber = inputStream.readInt();

            if (logger.isLoggable(java.util.logging.Level.FINER))
            {
                logger.finer("indexes available: " + indexNumber);
            }

            indexDataSize = inputStream.readInt();

            if (logger.isLoggable(java.util.logging.Level.FINER))
            {
                logger.finer("index data size: " + indexDataSize);
            }

            // Read indexes
            // make sure to sort them in order of offset to
            // be able to read the store without jumping arround in
            // the file
            java.util.TreeSet <IndexEntry> _indexes = new java.util.TreeSet <IndexEntry>(new IAC_IndexesComparator());

            for (int i = 0; i < this.indexNumber; i++)
            {
                IndexEntry index = new IndexEntry(inputStream);

                _indexes.add(index);
                size += index.getSize();
            }

            indexes = new IndexEntry[0];
            indexes = (IndexEntry[])_indexes.toArray(indexes);

            // Read store
            for (int i = 0; i < indexes.Length; i++)
            {
                IndexEntry index = indexes[i];

                // if (index.getType().equals(RPMIndexType.STRING_ARRAY) ||
                // index.getType().equals(RPMIndexType.STRING) ||
                // index.getType().equals(RPMIndexType.I18NSTRING)) {
                // if (i < (indexes.length - 1)) {
                // IndexEntry next = indexes[i + 1];
                //
                // length = next.getOffset() - index.getOffset();
                // } else {
                // length = indexDataSize - index.getOffset();
                // }
                //
                // // and initialize temporary space for data
                // stringData = new byte[(int) length];
                //
                // // and read it from stream
                // inputStream.readFully(stringData);
                // }
                DataTypeIf dataObject = null;

                if (logger.isLoggable(java.util.logging.Level.FINER))
                {
                    logger.finer("Reading for tag '"
                                 + store.getTagNameForId(index.getTag()) + "' '"
                                 + index.getCount() + "' entries of type '"
                                 + index.getType().getName() + "'");
                }

                dataObject = TypeFactory
                             .createFromStream(inputStream, index,
                                               (i < (indexes.Length - 1)) ? (indexes[i + 1]
                                                                             .getOffset() - index.getOffset())
                            : (indexDataSize - index.getOffset()));

                // adjust size
                size += dataObject.getSize();

                store.setTag(index.getTag(), dataObject);
            }

            if (logger.isLoggable(java.util.logging.Level.FINER))
            {
                logger.finer("");
            }

            if (logger.isLoggable(java.util.logging.Level.FINER))
            {
                logger.finer("Finished Reading Header");
            }
        }