1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.history.test;
14 import java.util.Arrays;
16 import org.simantics.databoard.Bindings;
17 import org.simantics.databoard.binding.Binding;
18 import org.simantics.databoard.serialization.Serializer;
19 import org.simantics.history.util.WeightedMedian;
21 public class TestWeightedMedian {
23 public static void main(String[] args) throws Exception {
25 WeightedMedian median = new WeightedMedian(5);
28 System.out.println(median);
30 System.out.println(median);
32 System.out.println(median);
34 System.out.println(median);
36 System.out.println(median);
38 System.out.println(median);
40 System.out.println(median);
42 System.out.println(median);
46 for (int i = 1; i < 10; i += 2) {
48 System.out.println(median);
51 for (int i = 10; i >= 2; i -= 2) {
53 System.out.println(median);
57 System.out.println(median);
59 Binding b = Bindings.getBinding( WeightedMedian.class );
61 WeightedMedian qu = (WeightedMedian) b.createDefault();
64 Serializer s = Bindings.getSerializerUnchecked( b );
65 byte[] data = s.serialize( median );
66 System.out.println(Arrays.toString(data));
67 WeightedMedian q2 = (WeightedMedian) s.deserialize( data );
68 System.out.println( b.toString(q2) );