Package java.util

Examples of java.util.SortedMap


   @SuppressWarnings("unchecked")
   private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
   {
      ObjectInputStream.GetField getField = in.readFields();
      SortedMap contents = (SortedMap) getField.get("contents", null);
      CompositeMetaType compositeType = (CompositeMetaType) getField.get("metaType", null);
      try
      {
         init(compositeType, contents);
      }
View Full Code Here


        assertEquals(m1.size(), m2.size());
        assertEquals(m1, m2);
    }

    public void testCopySortedMaps() {
        SortedMap orig = new TreeMap();
        populate(orig);
        assertSortedMapsEqual(orig, (SortedMap) _mgr.copyMap(orig));

        orig = new TreeMap(new CustomComparator());
        populate(orig);
View Full Code Here

        // store the updates in a persistent map
        storage = new PersistentMap(file);

        // sequence the updates
        SortedMap sequentialUpdates = new TreeMap();
        for(Iterator k = storage.keySet().iterator(); k.hasNext(); ) {
            Integer key = (Integer)k.next();
            Bufferlo valueBuffer = ((Chunk)storage.get(key)).getValue();
            sequentialUpdates.put(key, valueBuffer);
        }

        // replay all the updates from the file
        for(Iterator u = sequentialUpdates.keySet().iterator(); u.hasNext(); ) {
            Integer key = (Integer)u.next();
            Bufferlo update = (Bufferlo)sequentialUpdates.get(key);
            ListEventToBytes.toListEvent(update, this, byteCoder);
        }

        // prepare the next update id to use
        if(!sequentialUpdates.isEmpty()) {
            nextUpdateId = ((Integer)sequentialUpdates.lastKey()).intValue() + 1;
        }

        // now that we're up-to-date, listen for further events
        source.addListEventListener(this);
    }
View Full Code Here

            if ((maxRows != -1) && (processedRows == maxRows)) {
                isLimited = true;
                break;
            }
            Object[] columns = new Object[noOfColumns];
            SortedMap columnMap =
                new TreeMap(String.CASE_INSENSITIVE_ORDER);

            // JDBC uses 1 as the lowest index!
            for (int i = 1; i <= noOfColumns; i++) {
                Object value =  rs.getObject(i);
                if (rs.wasNull()) {
                    value = null;
                }
                columns[i-1] = value;
                columnMap.put(columnNames[i-1], value);
            }
            rowMap.add(columnMap);
            rowByIndex.add(columns);
            processedRows++;
        }
View Full Code Here

    * @return a <code>TermPositionVector</code> for the given text.
    */
   private TermPositionVector createTermPositionVector(String text)
   {
      // term -> TermVectorOffsetInfo[]
      final SortedMap termMap = new TreeMap();
      Reader r = new StringReader(text);
      TokenStream ts = index.getTextAnalyzer().tokenStream("", r);
      Token t = new Token();
      try
      {
         while ((t = ts.next(t)) != null)
         {
            String termText = t.term();
            TermVectorOffsetInfo[] info = (TermVectorOffsetInfo[])termMap.get(termText);
            if (info == null)
            {
               info = new TermVectorOffsetInfo[1];
            }
            else
            {
               TermVectorOffsetInfo[] tmp = info;
               info = new TermVectorOffsetInfo[tmp.length + 1];
               System.arraycopy(tmp, 0, info, 0, tmp.length);
            }
            info[info.length - 1] = new TermVectorOffsetInfo(t.startOffset(), t.endOffset());
            termMap.put(termText, info);
         }
      }
      catch (IOException e)
      {
         if (LOG.isTraceEnabled())
         {
            LOG.trace("An exception occurred: " + e.getMessage());
         }
      }

      return new TermPositionVector()
      {

         private String[] terms = (String[])termMap.keySet().toArray(new String[termMap.size()]);

         public int[] getTermPositions(int index)
         {
            return null;
         }

         public TermVectorOffsetInfo[] getOffsets(int index)
         {
            TermVectorOffsetInfo[] info = TermVectorOffsetInfo.EMPTY_OFFSET_INFO;
            if (index >= 0 && index < terms.length)
            {
               info = (TermVectorOffsetInfo[])termMap.get(terms[index]);
            }
            return info;
         }

         public String getField()
         {
            return "";
         }

         public int size()
         {
            return terms.length;
         }

         public String[] getTerms()
         {
            return terms;
         }

         public int[] getTermFrequencies()
         {
            int[] freqs = new int[terms.length];
            for (int i = 0; i < terms.length; i++)
            {
               freqs[i] = ((TermVectorOffsetInfo[])termMap.get(terms[i])).length;
            }
            return freqs;
         }

         public int indexOf(String term)
View Full Code Here

  @Override
  @SuppressWarnings("unchecked")
  public SortedMap subMap(Object fromKey, Object toKey) {
    read();
    final SortedMap subMap = ( (SortedMap) map ).subMap( fromKey, toKey );
    return new SortedSubMap( subMap );
  }
View Full Code Here

  @Override
  @SuppressWarnings("unchecked")
  public SortedMap headMap(Object toKey) {
    read();
    final SortedMap headMap = ( (SortedMap) map ).headMap( toKey );
    return new SortedSubMap( headMap );
  }
View Full Code Here

  @Override
  @SuppressWarnings("unchecked")
  public SortedMap tailMap(Object fromKey) {
    read();
    final SortedMap tailMap = ( (SortedMap) map ).tailMap( fromKey );
    return new SortedSubMap( tailMap );
  }
View Full Code Here

    }

    @Override
    @SuppressWarnings("unchecked")
    public SortedMap subMap(Object fromKey, Object toKey) {
      final SortedMap subMap = this.subMap.subMap( fromKey, toKey );
      return new SortedSubMap( subMap );
    }
View Full Code Here

    }

    @Override
    @SuppressWarnings("unchecked")
    public SortedMap headMap(Object toKey) {
      final SortedMap headMap = subMap.headMap( toKey );
      return new SortedSubMap( headMap );
    }
View Full Code Here

TOP

Related Classes of java.util.SortedMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.