commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1235799 - in /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive: BigDecimalWeight.java BigIntegerWeight.java FloatWeight.java LongWeight.java
Date Wed, 25 Jan 2012 15:23:39 GMT
Author: simonetripodi
Date: Wed Jan 25 15:23:38 2012
New Revision: 1235799

URL: http://svn.apache.org/viewvc?rev=1235799&view=rev
Log:
more predefined weights on top of Number implementations

Added:
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeight.java
  (with props)
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeight.java
  (with props)
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeight.java
  (with props)
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeight.java
  (with props)

Added: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeight.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeight.java?rev=1235799&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeight.java
(added)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeight.java
Wed Jan 25 15:23:38 2012
@@ -0,0 +1,72 @@
+package org.apache.commons.graph.weight.primitive;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static java.math.BigDecimal.ZERO;
+
+import java.math.BigDecimal;
+
+import org.apache.commons.graph.weight.OrderedMonoid;
+
+/**
+ * An {@link BigBigDecimalWeight} provides operations and properties
+ * for weights of type {@link BigDecimal}.
+ */
+public class BigDecimalWeight
+    implements OrderedMonoid<BigDecimal>
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    public BigDecimal zero()
+    {
+        return ZERO;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public BigDecimal append( BigDecimal s1, BigDecimal s2 )
+    {
+        if ( s1 == null || s2 == null )
+        {
+            return null;
+        }
+        return s1.add( s2 );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public BigDecimal inverse( BigDecimal element )
+    {
+        return element.negate();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int compare( BigDecimal o1, BigDecimal o2 )
+    {
+        return o1.compareTo( o2 );
+    }
+
+}

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeight.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeight.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeight.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeight.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeight.java?rev=1235799&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeight.java
(added)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeight.java
Wed Jan 25 15:23:38 2012
@@ -0,0 +1,72 @@
+package org.apache.commons.graph.weight.primitive;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static java.math.BigInteger.ZERO;
+
+import java.math.BigInteger;
+
+import org.apache.commons.graph.weight.OrderedMonoid;
+
+/**
+ * An {@link BigBigIntegerWeight} provides operations and properties
+ * for weights of type {@link BigInteger}.
+ */
+public class BigIntegerWeight
+    implements OrderedMonoid<BigInteger>
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    public BigInteger zero()
+    {
+        return ZERO;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public BigInteger append( BigInteger s1, BigInteger s2 )
+    {
+        if ( s1 == null || s2 == null )
+        {
+            return null;
+        }
+        return s1.add( s2 );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public BigInteger inverse( BigInteger element )
+    {
+        return element.negate();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int compare( BigInteger o1, BigInteger o2 )
+    {
+        return o1.compareTo( o2 );
+    }
+
+}

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeight.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeight.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeight.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeight.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeight.java?rev=1235799&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeight.java
(added)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeight.java
Wed Jan 25 15:23:38 2012
@@ -0,0 +1,68 @@
+package org.apache.commons.graph.weight.primitive;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.graph.weight.OrderedMonoid;
+
+/**
+ * A {@link FloatWeight} provides operations and properties
+ * for weights of type {@link Float}.
+ */
+public class FloatWeight
+    implements OrderedMonoid<Float>
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    public Float zero()
+    {
+        return 0.0F;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Float append( Float s1, Float s2 )
+    {
+        if ( s1 == null || s2 == null )
+        {
+            return null;
+        }
+        return s1 + s2;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Float inverse( Float element )
+    {
+        return -element;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int compare( Float s1, Float s2 )
+    {
+        return s1.compareTo( s2 );
+    }
+
+}

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeight.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeight.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeight.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeight.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeight.java?rev=1235799&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeight.java
(added)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeight.java
Wed Jan 25 15:23:38 2012
@@ -0,0 +1,68 @@
+package org.apache.commons.graph.weight.primitive;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.graph.weight.OrderedMonoid;
+
+/**
+ * A {@link LongWeight} provides operations and properties
+ * for weights of type {@link Long}.
+ */
+public class LongWeight
+    implements OrderedMonoid<Long>
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    public Long zero()
+    {
+        return 0L;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Long append( Long s1, Long s2 )
+    {
+        if ( s1 == null || s2 == null )
+        {
+            return null;
+        }
+        return s1 + s2;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Long inverse( Long element )
+    {
+        return -element;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int compare( Long s1, Long s2 )
+    {
+        return s1.compareTo( s2 );
+    }
+
+}

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeight.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeight.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeight.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message