~ubuntu-branches/ubuntu/oneiric/electric/oneiric

« back to all changes in this revision

Viewing changes to com/sun/electric/database/geometry/btree/unboxed/UnboxedInt.java

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2010-01-09 16:26:04 UTC
  • mfrom: (1.1.4 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100109162604-1ypvmy8ijmlc6oq7
Tags: 8.10-1
* New upstream version.
* debian/control
  - Add libjava3d-java and quilt build dependencies.
  - Update standards version to 3.8.3.
  - Add libjava3d-java as recommends to binary package.
* debian/rules
  - Use quilt patch system instead of simple patchsys.
  - Add java3d related jar files to DEB_JARS.
* debian/patches/*
  - Update as per current upstream source. Convert to quilt.
* debian/ant.properties
  - Do not disable 3D plugin anymore.
  - Use new property to disable compilation of OS X related classes.
* debian/wrappers/electric
  - Add java3d related jar files to runtime classpath.
* debian/README.source
  - Change text to the appropriate one for quilt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- tab-width: 4 -*-
 
2
 *
 
3
 * Electric(tm) VLSI Design System
 
4
 *
 
5
 * File: BTree.java
 
6
 *
 
7
 * Copyright (c) 2009 Sun Microsystems and Static Free Software
 
8
 *
 
9
 * Electric(tm) is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU Lesser General Public License as published by
 
11
 * the Free Software Foundation; either version 3 of the License, or
 
12
 * (at your option) any later version.
 
13
 *
 
14
 * Electric(tm) is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU Lesser General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU Lesser General Public License
 
20
 * along with Electric(tm); see the file COPYING.  If not, write to
 
21
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 
22
 * Boston, Mass 02111-1307, USA.
 
23
 */
 
24
package com.sun.electric.database.geometry.btree.unboxed;
 
25
 
 
26
import java.io.*;
 
27
 
 
28
/** A 32-bit <tt>int</tt> in unboxed form */
 
29
public class UnboxedInt implements UnboxedComparable<Integer> {
 
30
    public static final UnboxedInt instance = new UnboxedInt();
 
31
    public int getSize() { return 4; }
 
32
    public Integer deserialize(byte[] buf, int ofs) { return new Integer(deserializeInt(buf, ofs)); }
 
33
    public void serialize(Integer k, byte[] buf, int ofs) { serializeInt(k.intValue(), buf, ofs); }
 
34
    public int deserializeInt(byte[] buf, int ofs) {
 
35
        return
 
36
            ((buf[ofs+0] & 0xff) <<  0) |
 
37
            ((buf[ofs+1] & 0xff) <<  8) |
 
38
            ((buf[ofs+2] & 0xff) << 16) |
 
39
            ((buf[ofs+3] & 0xff) << 24);
 
40
    }
 
41
    public void serializeInt(int i, byte[] buf, int ofs) {
 
42
        buf[ofs+0] = (byte)((i >>  0) & 0xff);
 
43
        buf[ofs+1] = (byte)((i >>  8) & 0xff);
 
44
        buf[ofs+2] = (byte)((i >> 16) & 0xff);
 
45
        buf[ofs+3] = (byte)((i >> 24) & 0xff);
 
46
    }
 
47
    public int compare(byte[] buf1, int ofs1, byte[] buf2, int ofs2) {
 
48
        int buf1msb = buf1[ofs1+3] & 0xff;
 
49
        int buf2msb = buf2[ofs2+3] & 0xff;
 
50
        boolean buf1negative = (buf1msb >> 7) != 0;
 
51
        boolean buf2negative = (buf2msb >> 7) != 0;
 
52
        if ( buf1negative && !buf2negative) return -1;
 
53
        if (!buf1negative &&  buf2negative) return  1;
 
54
        buf1msb &= 127;
 
55
        buf2msb &= 127;
 
56
        int i;
 
57
        i = (buf1msb            ) - (buf2msb            ); if (i!=0) return i;
 
58
        i = (buf1[ofs1+2] & 0xff) - (buf2[ofs2+2] & 0xff); if (i!=0) return i;
 
59
        i = (buf1[ofs1+1] & 0xff) - (buf2[ofs2+1] & 0xff); if (i!=0) return i;
 
60
        i = (buf1[ofs1+0] & 0xff) - (buf2[ofs2+0] & 0xff); if (i!=0) return i;
 
61
        return 0;
 
62
    }
 
63
}