1
/* -*- tab-width: 4 -*-
3
* Electric(tm) VLSI Design System
7
* Copyright (c) 2009 Sun Microsystems and Static Free Software
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.
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.
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.
24
package com.sun.electric.database.geometry.btree.unboxed;
29
/** an implementation of Pair<A,B> in unboxed form */
30
public class UnboxedPair<A extends Serializable,B extends Serializable>
31
implements Unboxed<Pair<A,B>> {
33
private final Unboxed<A> ua;
34
private final Unboxed<B> ub;
35
public UnboxedPair(Unboxed<A> ua, Unboxed<B> ub) { this.ua = ua; this.ub = ub; }
36
public int getSize() { return ua.getSize()+ub.getSize(); }
37
public Pair<A,B> deserialize(byte[] buf, int ofs) {
38
A a = ua.deserialize(buf, ofs);
39
B b = ub.deserialize(buf, ofs+ua.getSize());
40
return new Pair<A,B>(a,b);
42
public void serialize(Pair<A,B> sme, byte[] buf, int ofs) {
43
ua.serialize(sme.getKey(), buf, ofs);
44
ub.serialize(sme.getValue(), buf, ofs+ua.getSize());