Changeset 2062


Ignore:
Timestamp:
Aug 24, 2006, 8:31:38 PM (14 years ago)
Author:
orlov
Message:
  • Implemented Entries function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/java/org/refal/plus/library/Table.java

    r2024 r2062  
    66
    77import org.refal.plus.*;
    8 import java.util.TreeMap;
     8import java.util.*;
    99import java.math.BigInteger;
    1010
     
    8787    }
    8888
     89    static public void Entries (Expr tab, Result res) throws RefalException
     90    {
     91        assert tab.getLen() == 1;
     92        try {
     93            TreeMap t = (TreeMap) tab.at(0);
     94            Expr[] e = new Expr[t.size()];
     95            Iterator i = t.entrySet().iterator();
     96            int j = 0;
     97            while (i.hasNext())
     98            {
     99                Map.Entry pair = (Map.Entry) i.next();
     100                e[j++] = new Expr(new Expr(pair.getKey()), new Expr(pair.getValue()));
     101            }
     102            res.assignUnsafe(e);
     103        } catch (ClassCastException _) {
     104            throw new RefalException("Table", "Entries", "Invalid argument");
     105        }
     106    }
     107
    89108    static public void Table_m_Copy (Expr tab, Result res) throws RefalException
    90109    {
Note: See TracChangeset for help on using the changeset viewer.