You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2015/04/28 21:15:26 UTC

[1/7] [lang] tabs replaced by spaces new tests added

Repository: commons-lang
Updated Branches:
  refs/heads/master 63d8a025e -> fd680a651


tabs replaced by spaces
new tests added

Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/06506aec
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/06506aec
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/06506aec

Branch: refs/heads/master
Commit: 06506aecf9e46441d08edab311e19e599d273fab
Parents: a399514
Author: beradrian <be...@yahoo.com>
Authored: Mon Mar 23 13:06:03 2015 +0200
Committer: beradrian <be...@yahoo.com>
Committed: Tue Apr 28 12:58:11 2015 +0300

----------------------------------------------------------------------
 .../org/apache/commons/lang3/ArrayUtils.java    | 476 +++++++++----------
 .../apache/commons/lang3/ArrayUtilsTest.java    |  18 +-
 2 files changed, 253 insertions(+), 241 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/06506aec/src/main/java/org/apache/commons/lang3/ArrayUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
index 8f21726..fb53bf8 100644
--- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
@@ -2043,10 +2043,10 @@ public class ArrayUtils {
             return;
         }
         for (int i = 0; i < len; i++) {
-	        byte aux = array[offset1 + i];
-	        array[offset1 + i] = array[offset2 + i];
-	        array[offset2 + i] = aux;
-    	}
+            byte aux = array[offset1 + i];
+            array[offset1 + i] = array[offset2 + i];
+            array[offset2 + i] = aux;
+        }
     }
 
     /**
@@ -2065,10 +2065,10 @@ public class ArrayUtils {
             return;
         }
         for (int i = 0; i < len; i++) {
-	        char aux = array[offset1 + i];
-	        array[offset1 + i] = array[offset2 + i];
-	        array[offset2 + i] = aux;
-    	}
+            char aux = array[offset1 + i];
+            array[offset1 + i] = array[offset2 + i];
+            array[offset2 + i] = aux;
+        }
     }
 
     /**
@@ -2087,10 +2087,10 @@ public class ArrayUtils {
             return;
         }
         for (int i = 0; i < len; i++) {
-	        double aux = array[offset1 + i];
-	        array[offset1 + i] = array[offset2 + i];
-	        array[offset2 + i] = aux;
-    	}
+            double aux = array[offset1 + i];
+            array[offset1 + i] = array[offset2 + i];
+            array[offset2 + i] = aux;
+        }
     }
 
     /**
@@ -2109,10 +2109,10 @@ public class ArrayUtils {
             return;
         }
         for (int i = 0; i < len; i++) {
-	        float aux = array[offset1 + i];
-	        array[offset1 + i] = array[offset2 + i];
-	        array[offset2 + i] = aux;
-    	}
+            float aux = array[offset1 + i];
+            array[offset1 + i] = array[offset2 + i];
+            array[offset2 + i] = aux;
+        }
     }
 
     /**
@@ -2131,10 +2131,10 @@ public class ArrayUtils {
             return;
         }
         for (int i = 0; i < len; i++) {
-	        int aux = array[offset1 + i];
-	        array[offset1 + i] = array[offset2 + i];
-	        array[offset2 + i] = aux;
-    	}
+            int aux = array[offset1 + i];
+            array[offset1 + i] = array[offset2 + i];
+            array[offset2 + i] = aux;
+        }
     }
 
     /**
@@ -2153,9 +2153,9 @@ public class ArrayUtils {
             return;
         }
         for (int i = 0; i < len; i++) {
-	        long aux = array[offset1 + i];
-	        array[offset1 + i] = array[offset2 + i];
-	        array[offset2 + i] = aux;
+            long aux = array[offset1 + i];
+            array[offset1 + i] = array[offset2 + i];
+            array[offset2 + i] = aux;
     	}
     }
 
@@ -2175,10 +2175,10 @@ public class ArrayUtils {
             return;
         }
         for (int i = 0; i < len; i++) {
-	        Object aux = array[offset1 + i];
-	        array[offset1 + i] = array[offset2 + i];
-	        array[offset2 + i] = aux;
-    	}
+            Object aux = array[offset1 + i];
+            array[offset1 + i] = array[offset2 + i];
+            array[offset2 + i] = aux;
+        }
     }
 
    /**
@@ -2197,10 +2197,10 @@ public class ArrayUtils {
             return;
         }
         for (int i = 0; i < len; i++) {
-	        short aux = array[offset1 + i];
-	        array[offset1 + i] = array[offset2 + i];
-	        array[offset2 + i] = aux;
-    	}
+            short aux = array[offset1 + i];
+            array[offset1 + i] = array[offset2 + i];
+            array[offset2 + i] = aux;
+        }
     }
 
     // Shift
@@ -2361,35 +2361,35 @@ public class ArrayUtils {
             return;
         }
         if (startIndexInclusive < 0) {
-        	startIndexInclusive = 0;
+            startIndexInclusive = 0;
         } 
         if (endIndexExclusive >= array.length) {
-        	endIndexExclusive = array.length;
+            endIndexExclusive = array.length;
         }        
         int n = endIndexExclusive - startIndexInclusive;
         if (n <= 1) {
-        	return;
+            return;
+        }
+        offset %= n;
+        if (offset < 0) {
+            offset += n;
+        }
+        while (n > 1 && offset > 0) {
+            int n_offset = n - offset;
+            
+            if (offset > n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+                n = offset;
+                offset -= n_offset;
+            } else if (offset < n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+                startIndexInclusive += offset;
+                n = n_offset;
+            } else {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+                break;
+            }
         }
-    	offset %= n;
-    	if (offset < 0) {
-    		offset += n;
-    	}
-		while (n > 1 && offset > 0) {
-			int n_offset = n - offset;
-			
-	    	if (offset > n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
-	    		n = offset;
-	    		offset -= n_offset;
-	    	} else if (offset < n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
-	    		startIndexInclusive += offset;
-	    		n = n_offset;
-	    	} else {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
-	    		break;
-	    	}
-		}
     }
 
     /**
@@ -2419,35 +2419,35 @@ public class ArrayUtils {
             return;
         }
         if (startIndexInclusive < 0) {
-        	startIndexInclusive = 0;
+            startIndexInclusive = 0;
         } 
         if (endIndexExclusive >= array.length) {
-        	endIndexExclusive = array.length;
+            endIndexExclusive = array.length;
         }        
         int n = endIndexExclusive - startIndexInclusive;
         if (n <= 1) {
-        	return;
+            return;
+        }
+        offset %= n;
+        if (offset < 0) {
+            offset += n;
+        }
+        while (n > 1 && offset > 0) {
+            int n_offset = n - offset;
+            
+            if (offset > n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+                n = offset;
+                offset -= n_offset;
+            } else if (offset < n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+                startIndexInclusive += offset;
+                n = n_offset;
+            } else {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+                break;
+            }
         }
-    	offset %= n;
-    	if (offset < 0) {
-    		offset += n;
-    	}
-		while (n > 1 && offset > 0) {
-			int n_offset = n - offset;
-			
-	    	if (offset > n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
-	    		n = offset;
-	    		offset -= n_offset;
-	    	} else if (offset < n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
-	    		startIndexInclusive += offset;
-	    		n = n_offset;
-	    	} else {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
-	    		break;
-	    	}
-		}
     }
 
     /**
@@ -2477,35 +2477,35 @@ public class ArrayUtils {
             return;
         }
         if (startIndexInclusive < 0) {
-        	startIndexInclusive = 0;
+            startIndexInclusive = 0;
         } 
         if (endIndexExclusive >= array.length) {
-        	endIndexExclusive = array.length;
+            endIndexExclusive = array.length;
         }        
         int n = endIndexExclusive - startIndexInclusive;
         if (n <= 1) {
-        	return;
+            return;
+        }
+        offset %= n;
+        if (offset < 0) {
+            offset += n;
+        }
+        while (n > 1 && offset > 0) {
+            int n_offset = n - offset;
+            
+            if (offset > n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+                n = offset;
+                offset -= n_offset;
+            } else if (offset < n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+                startIndexInclusive += offset;
+                n = n_offset;
+            } else {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+                break;
+            }
         }
-    	offset %= n;
-    	if (offset < 0) {
-    		offset += n;
-    	}
-		while (n > 1 && offset > 0) {
-			int n_offset = n - offset;
-			
-	    	if (offset > n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
-	    		n = offset;
-	    		offset -= n_offset;
-	    	} else if (offset < n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
-	    		startIndexInclusive += offset;
-	    		n = n_offset;
-	    	} else {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
-	    		break;
-	    	}
-		}
     }
 
     /**
@@ -2535,35 +2535,35 @@ public class ArrayUtils {
             return;
         }
         if (startIndexInclusive < 0) {
-        	startIndexInclusive = 0;
+            startIndexInclusive = 0;
         } 
         if (endIndexExclusive >= array.length) {
-        	endIndexExclusive = array.length;
+            endIndexExclusive = array.length;
         }        
         int n = endIndexExclusive - startIndexInclusive;
         if (n <= 1) {
-        	return;
+            return;
+        }
+        offset %= n;
+        if (offset < 0) {
+            offset += n;
+        }
+        while (n > 1 && offset > 0) {
+            int n_offset = n - offset;
+            
+            if (offset > n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+                n = offset;
+                offset -= n_offset;
+            } else if (offset < n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+                startIndexInclusive += offset;
+                n = n_offset;
+            } else {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+                break;
+            }
         }
-    	offset %= n;
-    	if (offset < 0) {
-    		offset += n;
-    	}
-		while (n > 1 && offset > 0) {
-			int n_offset = n - offset;
-			
-	    	if (offset > n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
-	    		n = offset;
-	    		offset -= n_offset;
-	    	} else if (offset < n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
-	    		startIndexInclusive += offset;
-	    		n = n_offset;
-	    	} else {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
-	    		break;
-	    	}
-		}
     }
 
     /**
@@ -2593,35 +2593,35 @@ public class ArrayUtils {
             return;
         }
         if (startIndexInclusive < 0) {
-        	startIndexInclusive = 0;
+            startIndexInclusive = 0;
         } 
         if (endIndexExclusive >= array.length) {
-        	endIndexExclusive = array.length;
+            endIndexExclusive = array.length;
         }        
         int n = endIndexExclusive - startIndexInclusive;
         if (n <= 1) {
-        	return;
+            return;
+        }
+        offset %= n;
+        if (offset < 0) {
+            offset += n;
+        }
+        while (n > 1 && offset > 0) {
+            int n_offset = n - offset;
+            
+            if (offset > n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+                n = offset;
+                offset -= n_offset;
+            } else if (offset < n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+                startIndexInclusive += offset;
+                n = n_offset;
+            } else {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+                break;
+            }
         }
-    	offset %= n;
-    	if (offset < 0) {
-    		offset += n;
-    	}
-		while (n > 1 && offset > 0) {
-			int n_offset = n - offset;
-			
-	    	if (offset > n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
-	    		n = offset;
-	    		offset -= n_offset;
-	    	} else if (offset < n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
-	    		startIndexInclusive += offset;
-	    		n = n_offset;
-	    	} else {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
-	    		break;
-	    	}
-		}
     }
 
     /**
@@ -2651,35 +2651,35 @@ public class ArrayUtils {
             return;
         }
         if (startIndexInclusive < 0) {
-        	startIndexInclusive = 0;
+            startIndexInclusive = 0;
         } 
         if (endIndexExclusive >= array.length) {
-        	endIndexExclusive = array.length;
+            endIndexExclusive = array.length;
         }        
         int n = endIndexExclusive - startIndexInclusive;
         if (n <= 1) {
-        	return;
+            return;
+        }
+        offset %= n;
+        if (offset < 0) {
+            offset += n;
+        }
+        while (n > 1 && offset > 0) {
+            int n_offset = n - offset;
+            
+            if (offset > n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+                n = offset;
+                offset -= n_offset;
+            } else if (offset < n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+                startIndexInclusive += offset;
+                n = n_offset;
+            } else {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+                break;
+            }
         }
-    	offset %= n;
-    	if (offset < 0) {
-    		offset += n;
-    	}
-		while (n > 1 && offset > 0) {
-			int n_offset = n - offset;
-			
-	    	if (offset > n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
-	    		n = offset;
-	    		offset -= n_offset;
-	    	} else if (offset < n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
-	    		startIndexInclusive += offset;
-	    		n = n_offset;
-	    	} else {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
-	    		break;
-	    	}
-		}
     }
 
     /**
@@ -2708,35 +2708,35 @@ public class ArrayUtils {
             return;
         }
         if (startIndexInclusive < 0) {
-        	startIndexInclusive = 0;
+            startIndexInclusive = 0;
         } 
         if (endIndexExclusive >= array.length) {
-        	endIndexExclusive = array.length;
+            endIndexExclusive = array.length;
         }        
         int n = endIndexExclusive - startIndexInclusive;
         if (n <= 1) {
-        	return;
+            return;
+        }
+        offset %= n;
+        if (offset < 0) {
+            offset += n;
+        }
+        while (n > 1 && offset > 0) {
+            int n_offset = n - offset;
+            
+            if (offset > n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+                n = offset;
+                offset -= n_offset;
+            } else if (offset < n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+                startIndexInclusive += offset;
+                n = n_offset;
+            } else {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+                break;
+            }
         }
-    	offset %= n;
-    	if (offset < 0) {
-    		offset += n;
-    	}
-		while (n > 1 && offset > 0) {
-			int n_offset = n - offset;
-			
-	    	if (offset > n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
-	    		n = offset;
-	    		offset -= n_offset;
-	    	} else if (offset < n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
-	    		startIndexInclusive += offset;
-	    		n = n_offset;
-	    	} else {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
-	    		break;
-	    	}
-		}
     }
 
     /**
@@ -2765,35 +2765,35 @@ public class ArrayUtils {
             return;
         }
         if (startIndexInclusive < 0) {
-        	startIndexInclusive = 0;
+            startIndexInclusive = 0;
         } 
         if (endIndexExclusive >= array.length) {
-        	endIndexExclusive = array.length;
+            endIndexExclusive = array.length;
         }        
         int n = endIndexExclusive - startIndexInclusive;
         if (n <= 1) {
-        	return;
+            return;
+        }
+        offset %= n;
+        if (offset < 0) {
+            offset += n;
+        }
+        while (n > 1 && offset > 0) {
+            int n_offset = n - offset;
+            
+            if (offset > n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+                n = offset;
+                offset -= n_offset;
+            } else if (offset < n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+                startIndexInclusive += offset;
+                n = n_offset;
+            } else {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+                break;
+            }
         }
-    	offset %= n;
-    	if (offset < 0) {
-    		offset += n;
-    	}
-		while (n > 1 && offset > 0) {
-			int n_offset = n - offset;
-			
-	    	if (offset > n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
-	    		n = offset;
-	    		offset -= n_offset;
-	    	} else if (offset < n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
-	    		startIndexInclusive += offset;
-	    		n = n_offset;
-	    	} else {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
-	    		break;
-	    	}
-		}
     }
 
     /**
@@ -2823,35 +2823,35 @@ public class ArrayUtils {
             return;
         }
         if (startIndexInclusive < 0) {
-        	startIndexInclusive = 0;
+            startIndexInclusive = 0;
         } 
         if (endIndexExclusive >= array.length) {
-        	endIndexExclusive = array.length;
+            endIndexExclusive = array.length;
         }        
         int n = endIndexExclusive - startIndexInclusive;
         if (n <= 1) {
-        	return;
+            return;
+        }
+        offset %= n;
+        if (offset < 0) {
+            offset += n;
+        }
+        while (n > 1 && offset > 0) {
+            int n_offset = n - offset;
+            
+            if (offset > n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+                n = offset;
+                offset -= n_offset;
+            } else if (offset < n_offset) {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+                startIndexInclusive += offset;
+                n = n_offset;
+            } else {
+                swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+                break;
+            }
         }
-    	offset %= n;
-    	if (offset < 0) {
-    		offset += n;
-    	}
-		while (n > 1 && offset > 0) {
-			int n_offset = n - offset;
-			
-	    	if (offset > n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
-	    		n = offset;
-	    		offset -= n_offset;
-	    	} else if (offset < n_offset) {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
-	    		startIndexInclusive += offset;
-	    		n = n_offset;
-	    	} else {
-	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
-	    		break;
-	    	}
-		}
     }
 
     // IndexOf search

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/06506aec/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
index 805375a..5633c9d 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
@@ -2123,9 +2123,21 @@ public class ArrayUtilsTest  {
     public void testSwapChar() {
         char[] array = new char[] {1, 2, 3};
         ArrayUtils.swap(array, 0, 2);
-        assertEquals(3, array[0]);
-        assertEquals(2, array[1]);
-        assertEquals(1, array[2]);
+        assertArrayEquals(new char[] {3, 2, 1}, array);
+        
+        array = new char[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 0);
+        assertArrayEquals(new char[] {1, 2, 3}, array);
+        
+        array = new char[] {1, 2, 3};
+        ArrayUtils.swap(array, 1, 0);
+        assertArrayEquals(new char[] {2, 1, 3}, array);
+    }
+    
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapCharOutOfBounds() {
+        char[] array = new char[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 5);
     }
 
     @Test


[6/7] [lang] Add LANG-1099 to changes.xml

Posted by br...@apache.org.
Add LANG-1099 to changes.xml


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/28a0672f
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/28a0672f
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/28a0672f

Branch: refs/heads/master
Commit: 28a0672f99847ea3de0b2de6fc64c4c8dccc451f
Parents: af8d0ab
Author: Benedikt Ritter <br...@apache.org>
Authored: Tue Apr 28 21:12:41 2015 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Tue Apr 28 21:12:41 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/28a0672f/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 3e25e06..5918d80 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -22,6 +22,7 @@
   <body>
 
   <release version="3.5" date="tba" description="tba">
+    <action issue="LANG-1099" type="add" dev="britter" due-to="Adrian Ber">Add swap and shift operations for arrays to ArrayUtils</action>
     <action issue="LANG-979" type="update" dev="britter" due-to="Bruno P. Kinoshita">TypeUtils.parameterizeWithOwner - wrong format descriptor for "invalid number of type parameters".</action>
     <action issue="LANG-1112" type="update" dev="britter">MultilineRecursiveToStringStyle largely unusable due to being package-private.</action>
     <action issue="LANG-1058" type="update" dev="djones" due-to="Leo Wang">StringUtils.uncapitalize performance improvement</action>


[3/7] [lang] examples added in Javadoc

Posted by br...@apache.org.
examples added in Javadoc

Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/c1501a24
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/c1501a24
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/c1501a24

Branch: refs/heads/master
Commit: c1501a24cb5f4ff073d539cc1f1a76ec5a1d01ae
Parents: 61095ef
Author: beradrian <be...@yahoo.com>
Authored: Tue Mar 24 12:17:24 2015 +0200
Committer: beradrian <be...@yahoo.com>
Committed: Tue Apr 28 12:58:12 2015 +0300

----------------------------------------------------------------------
 .../org/apache/commons/lang3/ArrayUtils.java    | 162 +++++++++++++++++++
 1 file changed, 162 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c1501a24/src/main/java/org/apache/commons/lang3/ArrayUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
index 881ba63..0afe0e4 100644
--- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
@@ -1855,6 +1855,15 @@ public class ArrayUtils {
      * <p>There is no special handling for multi-dimensional arrays.</p>
      *
      * <p>This method does nothing for a {@code null} input array.</p>
+     * 
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap(["1", "2", "3"], 0, 2) -> ["3", "2", "1"]</li>
+     *         <li>ArrayUtils.swap(["1", "2", "3"], 0, 0) -> ["1", "2", "3"]</li>
+     *         <li>ArrayUtils.swap(["1", "2", "3"], 1, 0) -> ["2", "1", "3"]</li>
+     *         <li>ArrayUtils.swap(["1", "2", "3"], 0, 5) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
      *
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
@@ -1873,6 +1882,15 @@ public class ArrayUtils {
      *
      * <p>This method does nothing for a {@code null} input array.</p>
      *
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([true, false, true], 0, 2) -> [true, false, true]</li>
+     *         <li>ArrayUtils.swap([true, false, true], 0, 0) -> [true, false, true]</li>
+     *         <li>ArrayUtils.swap([true, false, true], 1, 0) -> [false, true, true]</li>
+     *         <li>ArrayUtils.swap([true, false, true], 0, 5) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
      * @param offset2 the index of the second element to swap
@@ -1890,6 +1908,15 @@ public class ArrayUtils {
      *
      * <p>This method does nothing for a {@code null} input array.</p>
      *
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 2) -> [3, 2, 1]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 0) -> [1, 2, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 1, 0) -> [2, 1, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 5) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     *
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
      * @param offset2 the index of the second element to swap
@@ -1907,6 +1934,15 @@ public class ArrayUtils {
      *
      * <p>This method does nothing for a {@code null} input array.</p>
      *
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 2) -> [3, 2, 1]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 0) -> [1, 2, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 1, 0) -> [2, 1, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 5) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
      * @param offset2 the index of the second element to swap
@@ -1923,6 +1959,15 @@ public class ArrayUtils {
      * <p>Swaps two elements in the given array.</p>
      *
      * <p>This method does nothing for a {@code null} input array.</p>
+     * 
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 2) -> [3, 2, 1]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 0) -> [1, 2, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 1, 0) -> [2, 1, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 5) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
      *
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
@@ -1941,6 +1986,15 @@ public class ArrayUtils {
      *
      * <p>This method does nothing for a {@code null} input array.</p>
      *
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 2) -> [3, 2, 1]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 0) -> [1, 2, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 1, 0) -> [2, 1, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 5) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
      * @param offset2 the index of the second element to swap
@@ -1958,6 +2012,15 @@ public class ArrayUtils {
      *
      * <p>This method does nothing for a {@code null} input array.</p>
      *
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 2) -> [3, 2, 1]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 0) -> [1, 2, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 1, 0) -> [2, 1, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 5) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
      * @param offset2 the index of the second element to swap
@@ -1975,6 +2038,15 @@ public class ArrayUtils {
      *
      * <p>This method does nothing for a {@code null} input array.</p>
      *
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 2) -> [3, 2, 1]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 0) -> [1, 2, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 1, 0) -> [2, 1, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 5) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
      * @param offset2 the index of the second element to swap
@@ -1992,6 +2064,15 @@ public class ArrayUtils {
      *
      * <p>This method does nothing for a {@code null} input array.</p>
      *
+      * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 2) -> [3, 2, 1]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 0) -> [1, 2, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 1, 0) -> [2, 1, 3]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3], 0, 5) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
      * @param offset2 the index of the second element to swap
@@ -2009,6 +2090,15 @@ public class ArrayUtils {
      * 
      * <p>This method does nothing for a {@code null} input array.</p>
      * 
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap(["1", "2", "3", "4"], 0, 2, 1) -> ["3", "2", "1", "4"]</li>
+     *         <li>ArrayUtils.swap(["1", "2", "3", "4"], 0, 0, 1) -> ["1", "2", "3", "4"]</li>
+     *         <li>ArrayUtils.swap(["1", "2", "3", "4"], 2, 0, 2) -> ["3", "4", "1", "2"]</li>
+     *         <li>ArrayUtils.swap(["1", "2", "3", "4"], 0, 3, 3) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
      * @param offset2 the index of the second element in the series to swap
@@ -2031,6 +2121,15 @@ public class ArrayUtils {
      * 
      * <p>This method does nothing for a {@code null} input array.</p>
      * 
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([true, false, true, false], 0, 2, 1) -> [true, false, true, false]</li>
+     *         <li>ArrayUtils.swap([true, false, true, false], 0, 0, 1) -> [true, false, true, false]</li>
+     *         <li>ArrayUtils.swap([true, false, true, false], 0, 2, 2) -> [true, false, true, false]</li>
+     *         <li>ArrayUtils.swap([true, false, true, false], 0, 5, 3) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
      * @param offset2 the index of the second element in the series to swap
@@ -2054,6 +2153,15 @@ public class ArrayUtils {
      * 
      * <p>This method does nothing for a {@code null} input array.</p>
      * 
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 2, 1) -> [3, 2, 1, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 0, 1) -> [1, 2, 3, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 2, 0, 2) -> [3, 4, 1, 2]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 3, 3) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
      * @param offset2 the index of the second element in the series to swap
@@ -2076,6 +2184,15 @@ public class ArrayUtils {
      * 
      * <p>This method does nothing for a {@code null} input array.</p>
      * 
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 2, 1) -> [3, 2, 1, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 0, 1) -> [1, 2, 3, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 2, 0, 2) -> [3, 4, 1, 2]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 3, 3) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
      * @param offset2 the index of the second element in the series to swap
@@ -2098,6 +2215,15 @@ public class ArrayUtils {
      * 
      * <p>This method does nothing for a {@code null} input array.</p>
      * 
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 2, 1) -> [3, 2, 1, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 0, 1) -> [1, 2, 3, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 2, 0, 2) -> [3, 4, 1, 2]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 3, 3) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
      * @param offset2 the index of the second element in the series to swap
@@ -2120,6 +2246,15 @@ public class ArrayUtils {
      * 
      * <p>This method does nothing for a {@code null} input array.</p>
      * 
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 2, 1) -> [3, 2, 1, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 0, 1) -> [1, 2, 3, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 2, 0, 2) -> [3, 4, 1, 2]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 3, 3) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
      * @param offset2 the index of the second element in the series to swap
@@ -2142,6 +2277,15 @@ public class ArrayUtils {
      * 
      * <p>This method does nothing for a {@code null} input array.</p>
      * 
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 2, 1) -> [3, 2, 1, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 0, 1) -> [1, 2, 3, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 2, 0, 2) -> [3, 4, 1, 2]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 3, 3) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
      * @param offset2 the index of the second element in the series to swap
@@ -2164,6 +2308,15 @@ public class ArrayUtils {
      * 
      * <p>This method does nothing for a {@code null} input array.</p>
      * 
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 2, 1) -> [3, 2, 1, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 0, 1) -> [1, 2, 3, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 2, 0, 2) -> [3, 4, 1, 2]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 3, 3) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
+     * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
      * @param offset2 the index of the second element in the series to swap
@@ -2185,6 +2338,15 @@ public class ArrayUtils {
     * <p>Swaps a series of elements in the given array.</p>
     * 
     * <p>This method does nothing for a {@code null} input array.</p>
+     * 
+     * <p>Examples:
+     *     <ul>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 2, 1) -> [3, 2, 1, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 0, 1) -> [1, 2, 3, 4]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 2, 0, 2) -> [3, 4, 1, 2]</li>
+     *         <li>ArrayUtils.swap([1, 2, 3, 4], 0, 3, 3) -> ArrayOutOfBoundsException</li>
+     *     </ul>
+     * </p>
     * 
     * @param array the array to swap, may be {@code null}
     * @param offset1 the index of the first element in the series to swap


[2/7] [lang] swap and shift for arrays

Posted by br...@apache.org.
swap and shift for arrays

Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/a3995141
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/a3995141
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/a3995141

Branch: refs/heads/master
Commit: a3995141bf1b8a478e86fdbecc95f2b98f892647
Parents: 63d8a02
Author: beradrian <be...@yahoo.com>
Authored: Wed Mar 4 10:22:18 2015 +0200
Committer: beradrian <be...@yahoo.com>
Committed: Tue Apr 28 12:58:11 2015 +0300

----------------------------------------------------------------------
 .../org/apache/commons/lang3/ArrayUtils.java    | 1007 ++++++++++++++++++
 .../apache/commons/lang3/ArrayUtilsTest.java    |  723 +++++++++++++
 2 files changed, 1730 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a3995141/src/main/java/org/apache/commons/lang3/ArrayUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
index 9d0acee..8f21726 100644
--- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
@@ -1847,6 +1847,1013 @@ public class ArrayUtils {
         }
     }
 
+    // Swap
+    //-----------------------------------------------------------------------
+    /**
+     * <p>Swaps two elements in the given array.</p>
+     *
+     * <p>There is no special handling for multi-dimensional arrays.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array the array to swap, may be {@code null}
+     * @param offset1 the index of the first element to swap
+     * @param offset1 the index of the second element to swap
+     * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
+     */
+    public static void swap(final Object[] array, int offset1, int offset2) {
+        if (array == null) {
+            return;
+        }
+        swap(array, offset1, offset2, 1);
+    }
+
+    /**
+     * <p>Swaps two elements in the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to swap, may be {@code null}
+     * @param offset1 the index of the first element to swap
+     * @param offset1 the index of the second element to swap
+     * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
+     */
+    public static void swap(final long[] array, int offset1, int offset2) {
+        if (array == null) {
+            return;
+        }
+        swap(array, offset1, offset2, 1);
+    }
+
+    /**
+     * <p>Swaps two elements in the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to swap, may be {@code null}
+     * @param offset1 the index of the first element to swap
+     * @param offset1 the index of the second element to swap
+     * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
+     */
+    public static void swap(final int[] array, int offset1, int offset2) {
+        if (array == null) {
+            return;
+        }
+        swap(array, offset1, offset2, 1);
+    }
+
+    /**
+     * <p>Swaps two elements in the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to swap, may be {@code null}
+     * @param offset1 the index of the first element to swap
+     * @param offset1 the index of the second element to swap
+     * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
+     */
+    public static void swap(final short[] array, int offset1, int offset2) {
+        if (array == null) {
+            return;
+        }
+        swap(array, offset1, offset2, 1);
+    }
+
+    /**
+     * <p>Swaps two elements in the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to swap, may be {@code null}
+     * @param offset1 the index of the first element to swap
+     * @param offset1 the index of the second element to swap
+     * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
+     */
+    public static void swap(final char[] array, int offset1, int offset2) {
+        if (array == null) {
+            return;
+        }
+        swap(array, offset1, offset2, 1);
+    }
+
+    /**
+     * <p>Swaps two elements in the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to swap, may be {@code null}
+     * @param offset1 the index of the first element to swap
+     * @param offset1 the index of the second element to swap
+     * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
+     */
+    public static void swap(final byte[] array, int offset1, int offset2) {
+        if (array == null) {
+            return;
+        }
+        swap(array, offset1, offset2, 1);
+    }
+
+    /**
+     * <p>Swaps two elements in the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to swap, may be {@code null}
+     * @param offset1 the index of the first element to swap
+     * @param offset1 the index of the second element to swap
+     * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
+     */
+    public static void swap(final double[] array, int offset1, int offset2) {
+        if (array == null) {
+            return;
+        }
+        swap(array, offset1, offset2, 1);
+    }
+
+    /**
+     * <p>Swaps two elements in the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to swap, may be {@code null}
+     * @param offset1 the index of the first element to swap
+     * @param offset1 the index of the second element to swap
+     * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
+     */
+    public static void swap(final float[] array, int offset1, int offset2) {
+        if (array == null) {
+            return;
+        }
+        swap(array, offset1, offset2, 1);
+    }
+
+    /**
+     * <p>Swaps two elements in the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to swap, may be {@code null}
+     * @param offset1 the index of the first element to swap
+     * @param offset1 the index of the second element to swap
+     * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
+     */
+    public static void swap(final boolean[] array, int offset1, int offset2) {
+        if (array == null) {
+            return;
+        }
+        swap(array, offset1, offset2, 1);
+    }
+
+    /**
+     * <p>Swaps a series of elements in the given array.</p>
+     * 
+     * <p>This method does nothing for a {@code null} input array.</p>
+     * 
+     * @param array the array to swap, may be {@code null}
+     * @param offset1 the index of the first element in the series to swap
+     * @param offset1 the index of the second element in the series to swap
+     * @param len the number of elements to swap starting with the given indices
+     * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
+     */
+    public static void swap(final boolean[] array,  int offset1, int offset2, int len) {
+        if (array == null) {
+            return;
+        }
+        for (int i = 0; i < len; i++) {
+	        boolean aux = array[offset1 + i];
+	        array[offset1 + i] = array[offset2 + i];
+	        array[offset2 + i] = aux;
+    	}
+    }
+
+    /**
+     * <p>Swaps a series of elements in the given array.</p>
+     * 
+     * <p>This method does nothing for a {@code null} input array.</p>
+     * 
+     * @param array the array to swap, may be {@code null}
+     * @param offset1 the index of the first element in the series to swap
+     * @param offset1 the index of the second element in the series to swap
+     * @param len the number of elements to swap starting with the given indices
+     * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
+     */
+
+    public static void swap(final byte[] array,  int offset1, int offset2, int len) {
+        if (array == null) {
+            return;
+        }
+        for (int i = 0; i < len; i++) {
+	        byte aux = array[offset1 + i];
+	        array[offset1 + i] = array[offset2 + i];
+	        array[offset2 + i] = aux;
+    	}
+    }
+
+    /**
+     * <p>Swaps a series of elements in the given array.</p>
+     * 
+     * <p>This method does nothing for a {@code null} input array.</p>
+     * 
+     * @param array the array to swap, may be {@code null}
+     * @param offset1 the index of the first element in the series to swap
+     * @param offset1 the index of the second element in the series to swap
+     * @param len the number of elements to swap starting with the given indices
+     * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
+     */
+    public static void swap(final char[] array,  int offset1, int offset2, int len) {
+        if (array == null) {
+            return;
+        }
+        for (int i = 0; i < len; i++) {
+	        char aux = array[offset1 + i];
+	        array[offset1 + i] = array[offset2 + i];
+	        array[offset2 + i] = aux;
+    	}
+    }
+
+    /**
+     * <p>Swaps a series of elements in the given array.</p>
+     * 
+     * <p>This method does nothing for a {@code null} input array.</p>
+     * 
+     * @param array the array to swap, may be {@code null}
+     * @param offset1 the index of the first element in the series to swap
+     * @param offset1 the index of the second element in the series to swap
+     * @param len the number of elements to swap starting with the given indices
+     * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
+     */
+    public static void swap(final double[] array,  int offset1, int offset2, int len) {
+        if (array == null) {
+            return;
+        }
+        for (int i = 0; i < len; i++) {
+	        double aux = array[offset1 + i];
+	        array[offset1 + i] = array[offset2 + i];
+	        array[offset2 + i] = aux;
+    	}
+    }
+
+    /**
+     * <p>Swaps a series of elements in the given array.</p>
+     * 
+     * <p>This method does nothing for a {@code null} input array.</p>
+     * 
+     * @param array the array to swap, may be {@code null}
+     * @param offset1 the index of the first element in the series to swap
+     * @param offset1 the index of the second element in the series to swap
+     * @param len the number of elements to swap starting with the given indices
+     * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
+     */
+    public static void swap(final float[] array,  int offset1, int offset2, int len) {
+        if (array == null) {
+            return;
+        }
+        for (int i = 0; i < len; i++) {
+	        float aux = array[offset1 + i];
+	        array[offset1 + i] = array[offset2 + i];
+	        array[offset2 + i] = aux;
+    	}
+    }
+
+    /**
+     * <p>Swaps a series of elements in the given array.</p>
+     * 
+     * <p>This method does nothing for a {@code null} input array.</p>
+     * 
+     * @param array the array to swap, may be {@code null}
+     * @param offset1 the index of the first element in the series to swap
+     * @param offset1 the index of the second element in the series to swap
+     * @param len the number of elements to swap starting with the given indices
+     * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
+     */
+    public static void swap(final int[] array,  int offset1, int offset2, int len) {
+        if (array == null) {
+            return;
+        }
+        for (int i = 0; i < len; i++) {
+	        int aux = array[offset1 + i];
+	        array[offset1 + i] = array[offset2 + i];
+	        array[offset2 + i] = aux;
+    	}
+    }
+
+    /**
+     * <p>Swaps a series of elements in the given array.</p>
+     * 
+     * <p>This method does nothing for a {@code null} input array.</p>
+     * 
+     * @param array the array to swap, may be {@code null}
+     * @param offset1 the index of the first element in the series to swap
+     * @param offset1 the index of the second element in the series to swap
+     * @param len the number of elements to swap starting with the given indices
+     * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
+     */
+    public static void swap(final long[] array,  int offset1, int offset2, int len) {
+        if (array == null) {
+            return;
+        }
+        for (int i = 0; i < len; i++) {
+	        long aux = array[offset1 + i];
+	        array[offset1 + i] = array[offset2 + i];
+	        array[offset2 + i] = aux;
+    	}
+    }
+
+    /**
+     * <p>Swaps a series of elements in the given array.</p>
+     * 
+     * <p>This method does nothing for a {@code null} input array.</p>
+     * 
+     * @param array the array to swap, may be {@code null}
+     * @param offset1 the index of the first element in the series to swap
+     * @param offset1 the index of the second element in the series to swap
+     * @param len the number of elements to swap starting with the given indices
+     * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
+     */
+   public static void swap(final Object[] array,  int offset1, int offset2, int len) {
+        if (array == null) {
+            return;
+        }
+        for (int i = 0; i < len; i++) {
+	        Object aux = array[offset1 + i];
+	        array[offset1 + i] = array[offset2 + i];
+	        array[offset2 + i] = aux;
+    	}
+    }
+
+   /**
+    * <p>Swaps a series of elements in the given array.</p>
+    * 
+    * <p>This method does nothing for a {@code null} input array.</p>
+    * 
+    * @param array the array to swap, may be {@code null}
+    * @param offset1 the index of the first element in the series to swap
+    * @param offset1 the index of the second element in the series to swap
+    * @param len the number of elements to swap starting with the given indices
+    * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
+    */
+    public static void swap(final short[] array,  int offset1, int offset2, int len) {
+        if (array == null) {
+            return;
+        }
+        for (int i = 0; i < len; i++) {
+	        short aux = array[offset1 + i];
+	        array[offset1 + i] = array[offset2 + i];
+	        array[offset2 + i] = aux;
+    	}
+    }
+
+    // Shift
+    //-----------------------------------------------------------------------
+    /**
+     * <p>Shifts the order of the given array.</p>
+     *
+     * <p>There is no special handling for multi-dimensional arrays.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to shift, may be {@code null}
+     * @param offset how many position to the right to shift the array, if negative it will be shiftd to the left.
+     */
+    public static void shift(final Object[] array, int offset) {
+        if (array == null) {
+            return;
+        }
+        shift(array, 0, array.length, offset);
+    }
+
+    /**
+     * <p>Shifts the order of the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to shift, may be {@code null}
+     */
+    public static void shift(final long[] array, int offset) {
+        if (array == null) {
+            return;
+        }
+        shift(array, 0, array.length, offset);
+    }
+
+    /**
+     * <p>Shifts the order of the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to shift, may be {@code null}
+     */
+    public static void shift(final int[] array, int offset) {
+        if (array == null) {
+            return;
+        }
+        shift(array, 0, array.length, offset);
+    }
+
+    /**
+     * <p>Shifts the order of the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to shift, may be {@code null}
+     */
+    public static void shift(final short[] array, int offset) {
+        if (array == null) {
+            return;
+        }
+        shift(array, 0, array.length, offset);
+    }
+
+    /**
+     * <p>Shifts the order of the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to shift, may be {@code null}
+     */
+    public static void shift(final char[] array, int offset) {
+        if (array == null) {
+            return;
+        }
+        shift(array, 0, array.length, offset);
+    }
+
+    /**
+     * <p>Shifts the order of the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to shift, may be {@code null}
+     */
+    public static void shift(final byte[] array, int offset) {
+        if (array == null) {
+            return;
+        }
+        shift(array, 0, array.length, offset);
+    }
+
+    /**
+     * <p>Shifts the order of the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to shift, may be {@code null}
+     */
+    public static void shift(final double[] array, int offset) {
+        if (array == null) {
+            return;
+        }
+        shift(array, 0, array.length, offset);
+    }
+
+    /**
+     * <p>Shifts the order of the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to shift, may be {@code null}
+     */
+    public static void shift(final float[] array, int offset) {
+        if (array == null) {
+            return;
+        }
+        shift(array, 0, array.length, offset);
+    }
+
+    /**
+     * <p>Shifts the order of the given array.</p>
+     *
+     * <p>This method does nothing for a {@code null} input array.</p>
+     *
+     * @param array  the array to shift, may be {@code null}
+     */
+    public static void shift(final boolean[] array, int offset) {
+        if (array == null) {
+            return;
+        }
+        shift(array, 0, array.length, offset);
+    }
+
+    /**
+     * <p>
+     * Shifts the order of the given array in the given range.
+     * </p>
+     * 
+     * <p>
+     * This method does nothing for a {@code null} input array.
+     * </p>
+     * 
+     * @param array
+     *            the array to shift, may be {@code null}
+     * @param startIndexInclusive
+     *            the starting index. Undervalue (&lt;0) is promoted to 0, overvalue (&gt;array.length) results in no
+     *            change.
+     * @param endIndexExclusive
+     *            elements up to endIndex-1 are shiftd in the array. Undervalue (&lt; start index) results in no
+     *            change. Overvalue (&gt;array.length) is demoted to array length.
+     * @since 3.2
+     */
+    public static void shift(final boolean[] array, int startIndexInclusive, int endIndexExclusive, int offset) {
+        if (array == null) {
+            return;
+        }
+        if (startIndexInclusive >= array.length - 1 || endIndexExclusive <= 0) {
+            return;
+        }
+        if (startIndexInclusive < 0) {
+        	startIndexInclusive = 0;
+        } 
+        if (endIndexExclusive >= array.length) {
+        	endIndexExclusive = array.length;
+        }        
+        int n = endIndexExclusive - startIndexInclusive;
+        if (n <= 1) {
+        	return;
+        }
+    	offset %= n;
+    	if (offset < 0) {
+    		offset += n;
+    	}
+		while (n > 1 && offset > 0) {
+			int n_offset = n - offset;
+			
+	    	if (offset > n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+	    		n = offset;
+	    		offset -= n_offset;
+	    	} else if (offset < n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+	    		startIndexInclusive += offset;
+	    		n = n_offset;
+	    	} else {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+	    		break;
+	    	}
+		}
+    }
+
+    /**
+     * <p>
+     * Shifts the order of the given array in the given range.
+     * </p>
+     * 
+     * <p>
+     * This method does nothing for a {@code null} input array.
+     * </p>
+     * 
+     * @param array
+     *            the array to shift, may be {@code null}
+     * @param startIndexInclusive
+     *            the starting index. Undervalue (&lt;0) is promoted to 0, overvalue (&gt;array.length) results in no
+     *            change.
+     * @param endIndexExclusive
+     *            elements up to endIndex-1 are shiftd in the array. Undervalue (&lt; start index) results in no
+     *            change. Overvalue (&gt;array.length) is demoted to array length.
+     * @since 3.2
+     */
+    public static void shift(final byte[] array, int startIndexInclusive, int endIndexExclusive, int offset) {
+        if (array == null) {
+            return;
+        }
+        if (startIndexInclusive >= array.length - 1 || endIndexExclusive <= 0) {
+            return;
+        }
+        if (startIndexInclusive < 0) {
+        	startIndexInclusive = 0;
+        } 
+        if (endIndexExclusive >= array.length) {
+        	endIndexExclusive = array.length;
+        }        
+        int n = endIndexExclusive - startIndexInclusive;
+        if (n <= 1) {
+        	return;
+        }
+    	offset %= n;
+    	if (offset < 0) {
+    		offset += n;
+    	}
+		while (n > 1 && offset > 0) {
+			int n_offset = n - offset;
+			
+	    	if (offset > n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+	    		n = offset;
+	    		offset -= n_offset;
+	    	} else if (offset < n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+	    		startIndexInclusive += offset;
+	    		n = n_offset;
+	    	} else {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+	    		break;
+	    	}
+		}
+    }
+
+    /**
+     * <p>
+     * Shifts the order of the given array in the given range.
+     * </p>
+     * 
+     * <p>
+     * This method does nothing for a {@code null} input array.
+     * </p>
+     * 
+     * @param array
+     *            the array to shift, may be {@code null}
+     * @param startIndexInclusive
+     *            the starting index. Undervalue (&lt;0) is promoted to 0, overvalue (&gt;array.length) results in no
+     *            change.
+     * @param endIndexExclusive
+     *            elements up to endIndex-1 are shiftd in the array. Undervalue (&lt; start index) results in no
+     *            change. Overvalue (&gt;array.length) is demoted to array length.
+     * @since 3.2
+     */
+    public static void shift(final char[] array, int startIndexInclusive, int endIndexExclusive, int offset) {
+        if (array == null) {
+            return;
+        }
+        if (startIndexInclusive >= array.length - 1 || endIndexExclusive <= 0) {
+            return;
+        }
+        if (startIndexInclusive < 0) {
+        	startIndexInclusive = 0;
+        } 
+        if (endIndexExclusive >= array.length) {
+        	endIndexExclusive = array.length;
+        }        
+        int n = endIndexExclusive - startIndexInclusive;
+        if (n <= 1) {
+        	return;
+        }
+    	offset %= n;
+    	if (offset < 0) {
+    		offset += n;
+    	}
+		while (n > 1 && offset > 0) {
+			int n_offset = n - offset;
+			
+	    	if (offset > n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+	    		n = offset;
+	    		offset -= n_offset;
+	    	} else if (offset < n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+	    		startIndexInclusive += offset;
+	    		n = n_offset;
+	    	} else {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+	    		break;
+	    	}
+		}
+    }
+
+    /**
+     * <p>
+     * Shifts the order of the given array in the given range.
+     * </p>
+     * 
+     * <p>
+     * This method does nothing for a {@code null} input array.
+     * </p>
+     * 
+     * @param array
+     *            the array to shift, may be {@code null}
+     * @param startIndexInclusive
+     *            the starting index. Undervalue (&lt;0) is promoted to 0, overvalue (&gt;array.length) results in no
+     *            change.
+     * @param endIndexExclusive
+     *            elements up to endIndex-1 are shiftd in the array. Undervalue (&lt; start index) results in no
+     *            change. Overvalue (&gt;array.length) is demoted to array length.
+     * @since 3.2
+     */
+    public static void shift(final double[] array, int startIndexInclusive, int endIndexExclusive, int offset) {
+        if (array == null) {
+            return;
+        }
+        if (startIndexInclusive >= array.length - 1 || endIndexExclusive <= 0) {
+            return;
+        }
+        if (startIndexInclusive < 0) {
+        	startIndexInclusive = 0;
+        } 
+        if (endIndexExclusive >= array.length) {
+        	endIndexExclusive = array.length;
+        }        
+        int n = endIndexExclusive - startIndexInclusive;
+        if (n <= 1) {
+        	return;
+        }
+    	offset %= n;
+    	if (offset < 0) {
+    		offset += n;
+    	}
+		while (n > 1 && offset > 0) {
+			int n_offset = n - offset;
+			
+	    	if (offset > n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+	    		n = offset;
+	    		offset -= n_offset;
+	    	} else if (offset < n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+	    		startIndexInclusive += offset;
+	    		n = n_offset;
+	    	} else {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+	    		break;
+	    	}
+		}
+    }
+
+    /**
+     * <p>
+     * Shifts the order of the given array in the given range.
+     * </p>
+     * 
+     * <p>
+     * This method does nothing for a {@code null} input array.
+     * </p>
+     * 
+     * @param array
+     *            the array to shift, may be {@code null}
+     * @param startIndexInclusive
+     *            the starting index. Undervalue (&lt;0) is promoted to 0, overvalue (&gt;array.length) results in no
+     *            change.
+     * @param endIndexExclusive
+     *            elements up to endIndex-1 are shiftd in the array. Undervalue (&lt; start index) results in no
+     *            change. Overvalue (&gt;array.length) is demoted to array length.
+     * @since 3.2
+     */
+    public static void shift(final float[] array, int startIndexInclusive, int endIndexExclusive, int offset) {
+        if (array == null) {
+            return;
+        }
+        if (startIndexInclusive >= array.length - 1 || endIndexExclusive <= 0) {
+            return;
+        }
+        if (startIndexInclusive < 0) {
+        	startIndexInclusive = 0;
+        } 
+        if (endIndexExclusive >= array.length) {
+        	endIndexExclusive = array.length;
+        }        
+        int n = endIndexExclusive - startIndexInclusive;
+        if (n <= 1) {
+        	return;
+        }
+    	offset %= n;
+    	if (offset < 0) {
+    		offset += n;
+    	}
+		while (n > 1 && offset > 0) {
+			int n_offset = n - offset;
+			
+	    	if (offset > n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+	    		n = offset;
+	    		offset -= n_offset;
+	    	} else if (offset < n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+	    		startIndexInclusive += offset;
+	    		n = n_offset;
+	    	} else {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+	    		break;
+	    	}
+		}
+    }
+
+    /**
+     * <p>
+     * Shifts the order of the given array in the given range.
+     * </p>
+     * 
+     * <p>
+     * This method does nothing for a {@code null} input array.
+     * </p>
+     * 
+     * @param array
+     *            the array to shift, may be {@code null}
+     * @param startIndexInclusive
+     *            the starting index. Undervalue (&lt;0) is promoted to 0, overvalue (&gt;array.length) results in no
+     *            change.
+     * @param endIndexExclusive
+     *            elements up to endIndex-1 are shiftd in the array. Undervalue (&lt; start index) results in no
+     *            change. Overvalue (&gt;array.length) is demoted to array length.
+     * @since 3.2
+     */
+    public static void shift(final int[] array, int startIndexInclusive, int endIndexExclusive, int offset) {
+        if (array == null) {
+            return;
+        }
+        if (startIndexInclusive >= array.length - 1 || endIndexExclusive <= 0) {
+            return;
+        }
+        if (startIndexInclusive < 0) {
+        	startIndexInclusive = 0;
+        } 
+        if (endIndexExclusive >= array.length) {
+        	endIndexExclusive = array.length;
+        }        
+        int n = endIndexExclusive - startIndexInclusive;
+        if (n <= 1) {
+        	return;
+        }
+    	offset %= n;
+    	if (offset < 0) {
+    		offset += n;
+    	}
+		while (n > 1 && offset > 0) {
+			int n_offset = n - offset;
+			
+	    	if (offset > n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+	    		n = offset;
+	    		offset -= n_offset;
+	    	} else if (offset < n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+	    		startIndexInclusive += offset;
+	    		n = n_offset;
+	    	} else {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+	    		break;
+	    	}
+		}
+    }
+
+    /**
+     * <p>
+     * Shifts the order of the given array in the given range.
+     * </p>
+     * 
+     * <p>
+     * This method does nothing for a {@code null} input array.
+     * </p>
+     * 
+     * @param array
+     *            the array to shift, may be {@code null}
+     * @param startIndexInclusive
+     *            the starting index. Undervalue (&lt;0) is promoted to 0, overvalue (&gt;array.length) results in no
+     *            change.
+     * @param endIndexExclusive
+     *            elements up to endIndex-1 are shiftd in the array. Undervalue (&lt; start index) results in no
+     *            change. Overvalue (&gt;array.length) is demoted to array length.
+     */
+    public static void shift(final long[] array, int startIndexInclusive, int endIndexExclusive, int offset) {
+        if (array == null) {
+            return;
+        }
+        if (startIndexInclusive >= array.length - 1 || endIndexExclusive <= 0) {
+            return;
+        }
+        if (startIndexInclusive < 0) {
+        	startIndexInclusive = 0;
+        } 
+        if (endIndexExclusive >= array.length) {
+        	endIndexExclusive = array.length;
+        }        
+        int n = endIndexExclusive - startIndexInclusive;
+        if (n <= 1) {
+        	return;
+        }
+    	offset %= n;
+    	if (offset < 0) {
+    		offset += n;
+    	}
+		while (n > 1 && offset > 0) {
+			int n_offset = n - offset;
+			
+	    	if (offset > n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+	    		n = offset;
+	    		offset -= n_offset;
+	    	} else if (offset < n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+	    		startIndexInclusive += offset;
+	    		n = n_offset;
+	    	} else {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+	    		break;
+	    	}
+		}
+    }
+
+    /**
+     * <p>
+     * Shifts the order of the given array in the given range.
+     * </p>
+     * 
+     * <p>
+     * This method does nothing for a {@code null} input array.
+     * </p>
+     * 
+     * @param array
+     *            the array to shift, may be {@code null}
+     * @param startIndexInclusive
+     *            the starting index. Undervalue (&lt;0) is promoted to 0, overvalue (&gt;array.length) results in no
+     *            change.
+     * @param endIndexExclusive
+     *            elements up to endIndex-1 are shiftd in the array. Undervalue (&lt; start index) results in no
+     *            change. Overvalue (&gt;array.length) is demoted to array length.
+     */
+    public static void shift(final Object[] array, int startIndexInclusive, int endIndexExclusive, int offset) {
+        if (array == null) {
+            return;
+        }
+        if (startIndexInclusive >= array.length - 1 || endIndexExclusive <= 0) {
+            return;
+        }
+        if (startIndexInclusive < 0) {
+        	startIndexInclusive = 0;
+        } 
+        if (endIndexExclusive >= array.length) {
+        	endIndexExclusive = array.length;
+        }        
+        int n = endIndexExclusive - startIndexInclusive;
+        if (n <= 1) {
+        	return;
+        }
+    	offset %= n;
+    	if (offset < 0) {
+    		offset += n;
+    	}
+		while (n > 1 && offset > 0) {
+			int n_offset = n - offset;
+			
+	    	if (offset > n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+	    		n = offset;
+	    		offset -= n_offset;
+	    	} else if (offset < n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+	    		startIndexInclusive += offset;
+	    		n = n_offset;
+	    	} else {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+	    		break;
+	    	}
+		}
+    }
+
+    /**
+     * <p>
+     * Shifts the order of the given array in the given range.
+     * </p>
+     * 
+     * <p>
+     * This method does nothing for a {@code null} input array.
+     * </p>
+     * 
+     * @param array
+     *            the array to shift, may be {@code null}
+     * @param startIndexInclusive
+     *            the starting index. Undervalue (&lt;0) is promoted to 0, overvalue (&gt;array.length) results in no
+     *            change.
+     * @param endIndexExclusive
+     *            elements up to endIndex-1 are shiftd in the array. Undervalue (&lt; start index) results in no
+     *            change. Overvalue (&gt;array.length) is demoted to array length.
+     * @since 3.2
+     */
+    public static void shift(final short[] array, int startIndexInclusive, int endIndexExclusive, int offset) {
+        if (array == null) {
+            return;
+        }
+        if (startIndexInclusive >= array.length - 1 || endIndexExclusive <= 0) {
+            return;
+        }
+        if (startIndexInclusive < 0) {
+        	startIndexInclusive = 0;
+        } 
+        if (endIndexExclusive >= array.length) {
+        	endIndexExclusive = array.length;
+        }        
+        int n = endIndexExclusive - startIndexInclusive;
+        if (n <= 1) {
+        	return;
+        }
+    	offset %= n;
+    	if (offset < 0) {
+    		offset += n;
+    	}
+		while (n > 1 && offset > 0) {
+			int n_offset = n - offset;
+			
+	    	if (offset > n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n - n_offset,  n_offset);
+	    		n = offset;
+	    		offset -= n_offset;
+	    	} else if (offset < n_offset) {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset,  offset);
+	    		startIndexInclusive += offset;
+	    		n = n_offset;
+	    	} else {
+	    		swap(array, startIndexInclusive, startIndexInclusive + n_offset, offset);
+	    		break;
+	    	}
+		}
+    }
+
     // IndexOf search
     // ----------------------------------------------------------------------
 

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/a3995141/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
index 609b169..805375a 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
@@ -2118,7 +2118,730 @@ public class ArrayUtilsTest  {
         assertEquals(null, array);
     }
     
+    //-----------------------------------------------------------------------
+    @Test
+    public void testSwapChar() {
+        char[] array = new char[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 2);
+        assertEquals(3, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(1, array[2]);
+    }
+
+    @Test
+    public void testSwapCharRange() {
+        char[] array = new char[] {1, 2, 3, 4};
+        ArrayUtils.swap(array, 0, 2, 2);
+        assertEquals(3, array[0]);
+        assertEquals(4, array[1]);
+        assertEquals(1, array[2]);
+        assertEquals(2, array[3]);
+    }
+
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapCharOutOfRange() {
+        char[] array = new char[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 3);
+    }
+
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapCharOutOfRangeLen() {
+        char[] array = new char[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 2, 2);
+    }
+    
+    @Test
+    public void testSwapFloat() {
+        float[] array = new float[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 2);
+        assertEquals(3, array[0], 0);
+        assertEquals(2, array[1], 0);
+        assertEquals(1, array[2], 0);
+    }
+
+    @Test
+    public void testSwapFloatRange() {
+        float[] array = new float[] {1, 2, 3, 4};
+        ArrayUtils.swap(array, 0, 2, 2);
+        assertEquals(3, array[0], 0);
+        assertEquals(4, array[1], 0);
+        assertEquals(1, array[2], 0);
+        assertEquals(2, array[3], 0);
+    }
+
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapFloatOutOfRange() {
+        float[] array = new float[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 3);
+    }
+
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapFloatOutOfRangeLen() {
+        float[] array = new float[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 2, 2);
+    }
+    
+    @Test
+    public void testSwapDouble() {
+        double[] array = new double[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 2);
+        assertEquals(3, array[0], 0);
+        assertEquals(2, array[1], 0);
+        assertEquals(1, array[2], 0);
+    }
+
+    @Test
+    public void testSwapDoubleRange() {
+        double[] array = new double[] {1, 2, 3, 4};
+        ArrayUtils.swap(array, 0, 2, 2);
+        assertEquals(3, array[0], 0);
+        assertEquals(4, array[1], 0);
+        assertEquals(1, array[2], 0);
+        assertEquals(2, array[3], 0);
+    }
+
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapDoubleOutOfRange() {
+        double[] array = new double[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 3);
+    }
 
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapDoubleOutOfRangeLen() {
+        double[] array = new double[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 2, 2);
+    }
+    
+    @Test
+    public void testSwapInt() {
+        int[] array = new int[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 2);
+        assertEquals(3, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(1, array[2]);
+    }
+
+    @Test
+    public void testSwapIntRange() {
+        int[] array = new int[] {1, 2, 3, 4};
+        ArrayUtils.swap(array, 0, 2, 2);
+        assertEquals(3, array[0]);
+        assertEquals(4, array[1]);
+        assertEquals(1, array[2]);
+        assertEquals(2, array[3]);
+    }
+
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapIntOutOfRange() {
+        int[] array = new int[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 3);
+    }
+
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapIntOutOfRangeLen() {
+        int[] array = new int[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 2, 2);
+    }
+    
+    @Test
+    public void testSwapLong() {
+        long[] array = new long[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 2);
+        assertEquals(3, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(1, array[2]);
+    }
+
+    @Test
+    public void testSwapLongRange() {
+        long[] array = new long[] {1, 2, 3, 4};
+        ArrayUtils.swap(array, 0, 2, 2);
+        assertEquals(3, array[0]);
+        assertEquals(4, array[1]);
+        assertEquals(1, array[2]);
+        assertEquals(2, array[3]);
+    }
+
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapLongOutOfRange() {
+        long[] array = new long[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 3);
+    }
+
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapLongOutOfRangeLen() {
+        long[] array = new long[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 2, 2);
+    }
+
+    @Test
+    public void testSwapObject() {
+        String[] array = new String[] {"1", "2", "3"};
+        ArrayUtils.swap(array, 0, 2);
+        assertEquals("3", array[0]);
+        assertEquals("2", array[1]);
+        assertEquals("1", array[2]);
+    }
+
+    @Test
+    public void testSwapObjectRange() {
+        String[] array = new String[] {"1", "2", "3", "4"};
+        ArrayUtils.swap(array, 0, 2, 2);
+        assertEquals("3", array[0]);
+        assertEquals("4", array[1]);
+        assertEquals("1", array[2]);
+        assertEquals("2", array[3]);
+    }
+
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapObjectOutOfRange() {
+        String[] array = new String[] {"1", "2", "3"};
+        ArrayUtils.swap(array, 0, 3);
+    }
+
+    @Test(expected = ArrayIndexOutOfBoundsException.class)
+    public void testSwapObjectOutOfRangeLen() {
+        String[] array = new String[] {"1", "2", "3"};
+        ArrayUtils.swap(array, 0, 2, 2);
+    }
+
+    //-----------------------------------------------------------------------
+    @Test
+    public void testShiftDouble() {
+        double[] array = new double[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1);
+        assertEquals(4, array[0], 0);
+        assertEquals(1, array[1], 0);
+        assertEquals(2, array[2], 0);
+        assertEquals(3, array[3], 0);
+        ArrayUtils.shift(array, -1);
+        assertEquals(1, array[0], 0);
+        assertEquals(2, array[1], 0);
+        assertEquals(3, array[2], 0);
+        assertEquals(4, array[3], 0);
+        ArrayUtils.shift(array, 5);
+        assertEquals(4, array[0], 0);
+        assertEquals(1, array[1], 0);
+        assertEquals(2, array[2], 0);
+        assertEquals(3, array[3], 0);
+        ArrayUtils.shift(array, -3);
+        assertEquals(3, array[0], 0);
+        assertEquals(4, array[1], 0);
+        assertEquals(1, array[2], 0);
+        assertEquals(2, array[3], 0);
+    }
+
+    @Test
+    public void testShiftRangeDouble() {
+        double[] array = new double[] {1, 2, 3, 4, 5};
+        ArrayUtils.shift(array, 1, 3, 1);
+        assertEquals(1, array[0], 0);
+        assertEquals(3, array[1], 0);
+        assertEquals(2, array[2], 0);
+        assertEquals(4, array[3], 0);
+        assertEquals(5, array[4], 0);
+        ArrayUtils.shift(array, 1, 4, 2);
+        assertEquals(1, array[0], 0);
+        assertEquals(2, array[1], 0);
+        assertEquals(4, array[2], 0);
+        assertEquals(3, array[3], 0);
+        assertEquals(5, array[4], 0);
+    }
+
+    @Test
+    public void testShiftRangeNoElemDouble() {
+        double[] array = new double[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1, 1, 1);
+        assertEquals(1, array[0], 0);
+        assertEquals(2, array[1], 0);
+        assertEquals(3, array[2], 0);
+        assertEquals(4, array[3], 0);
+    }
+
+    @Test
+    public void testShiftAllDouble() {
+        double[] array = new double[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 4);
+        assertEquals(1, array[0], 0);
+        assertEquals(2, array[1], 0);
+        assertEquals(3, array[2], 0);
+        assertEquals(4, array[3], 0);
+        ArrayUtils.shift(array, -4);
+        assertEquals(1, array[0], 0);
+        assertEquals(2, array[1], 0);
+        assertEquals(3, array[2], 0);
+        assertEquals(4, array[3], 0);
+    }
+    
+    @Test
+    public void testShiftFloat() {
+        float[] array = new float[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1);
+        assertEquals(4, array[0], 0);
+        assertEquals(1, array[1], 0);
+        assertEquals(2, array[2], 0);
+        assertEquals(3, array[3], 0);
+        ArrayUtils.shift(array, -1);
+        assertEquals(1, array[0], 0);
+        assertEquals(2, array[1], 0);
+        assertEquals(3, array[2], 0);
+        assertEquals(4, array[3], 0);
+        ArrayUtils.shift(array, 5);
+        assertEquals(4, array[0], 0);
+        assertEquals(1, array[1], 0);
+        assertEquals(2, array[2], 0);
+        assertEquals(3, array[3], 0);
+        ArrayUtils.shift(array, -3);
+        assertEquals(3, array[0], 0);
+        assertEquals(4, array[1], 0);
+        assertEquals(1, array[2], 0);
+        assertEquals(2, array[3], 0);
+    }
+
+    @Test
+    public void testShiftRangeFloat() {
+        float[] array = new float[] {1, 2, 3, 4, 5};
+        ArrayUtils.shift(array, 1, 3, 1);
+        assertEquals(1, array[0], 0);
+        assertEquals(3, array[1], 0);
+        assertEquals(2, array[2], 0);
+        assertEquals(4, array[3], 0);
+        assertEquals(5, array[4], 0);
+        ArrayUtils.shift(array, 1, 4, 2);
+        assertEquals(1, array[0], 0);
+        assertEquals(2, array[1], 0);
+        assertEquals(4, array[2], 0);
+        assertEquals(3, array[3], 0);
+        assertEquals(5, array[4], 0);
+    }
+
+    @Test
+    public void testShiftRangeNoElemFloat() {
+        float[] array = new float[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1, 1, 1);
+        assertEquals(1, array[0], 0);
+        assertEquals(2, array[1], 0);
+        assertEquals(3, array[2], 0);
+        assertEquals(4, array[3], 0);
+    }
+
+    @Test
+    public void testShiftAllFloat() {
+        float[] array = new float[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 4);
+        assertEquals(1, array[0], 0);
+        assertEquals(2, array[1], 0);
+        assertEquals(3, array[2], 0);
+        assertEquals(4, array[3], 0);
+        ArrayUtils.shift(array, -4);
+        assertEquals(1, array[0], 0);
+        assertEquals(2, array[1], 0);
+        assertEquals(3, array[2], 0);
+        assertEquals(4, array[3], 0);
+    }
+    
+    @Test
+    public void testShiftShort() {
+        short[] array = new short[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1);
+        assertEquals(4, array[0]);
+        assertEquals(1, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(3, array[3]);
+        ArrayUtils.shift(array, -1);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+        ArrayUtils.shift(array, 5);
+        assertEquals(4, array[0]);
+        assertEquals(1, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(3, array[3]);
+        ArrayUtils.shift(array, -3);
+        assertEquals(3, array[0]);
+        assertEquals(4, array[1]);
+        assertEquals(1, array[2]);
+        assertEquals(2, array[3]);
+    }
+
+    @Test
+    public void testShiftRangeShort() {
+        short[] array = new short[] {1, 2, 3, 4, 5};
+        ArrayUtils.shift(array, 1, 3, 1);
+        assertEquals(1, array[0]);
+        assertEquals(3, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(4, array[3]);
+        assertEquals(5, array[4]);
+        ArrayUtils.shift(array, 1, 4, 2);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(4, array[2]);
+        assertEquals(3, array[3]);
+        assertEquals(5, array[4]);
+    }
+
+    @Test
+    public void testShiftRangeNoElemShort() {
+        short[] array = new short[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1, 1, 1);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+    }
+
+    @Test
+    public void testShiftAllShort() {
+        short[] array = new short[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 4);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+        ArrayUtils.shift(array, -4);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+    }
+    
+    @Test
+    public void testShiftByte() {
+        byte[] array = new byte[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1);
+        assertEquals(4, array[0]);
+        assertEquals(1, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(3, array[3]);
+        ArrayUtils.shift(array, -1);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+        ArrayUtils.shift(array, 5);
+        assertEquals(4, array[0]);
+        assertEquals(1, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(3, array[3]);
+        ArrayUtils.shift(array, -3);
+        assertEquals(3, array[0]);
+        assertEquals(4, array[1]);
+        assertEquals(1, array[2]);
+        assertEquals(2, array[3]);
+    }
+
+    @Test
+    public void testShiftRangeByte() {
+        byte[] array = new byte[] {1, 2, 3, 4, 5};
+        ArrayUtils.shift(array, 1, 3, 1);
+        assertEquals(1, array[0]);
+        assertEquals(3, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(4, array[3]);
+        assertEquals(5, array[4]);
+        ArrayUtils.shift(array, 1, 4, 2);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(4, array[2]);
+        assertEquals(3, array[3]);
+        assertEquals(5, array[4]);
+    }
+
+    @Test
+    public void testShiftRangeNoElemByte() {
+        byte[] array = new byte[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1, 1, 1);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+    }
+
+    @Test
+    public void testShiftAllByte() {
+        byte[] array = new byte[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 4);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+        ArrayUtils.shift(array, -4);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+    }
+    
+    @Test
+    public void testShiftChar() {
+        char[] array = new char[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1);
+        assertEquals(4, array[0]);
+        assertEquals(1, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(3, array[3]);
+        ArrayUtils.shift(array, -1);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+        ArrayUtils.shift(array, 5);
+        assertEquals(4, array[0]);
+        assertEquals(1, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(3, array[3]);
+        ArrayUtils.shift(array, -3);
+        assertEquals(3, array[0]);
+        assertEquals(4, array[1]);
+        assertEquals(1, array[2]);
+        assertEquals(2, array[3]);
+    }
+
+    @Test
+    public void testShiftRangeChar() {
+        char[] array = new char[] {1, 2, 3, 4, 5};
+        ArrayUtils.shift(array, 1, 3, 1);
+        assertEquals(1, array[0]);
+        assertEquals(3, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(4, array[3]);
+        assertEquals(5, array[4]);
+        ArrayUtils.shift(array, 1, 4, 2);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(4, array[2]);
+        assertEquals(3, array[3]);
+        assertEquals(5, array[4]);
+    }
+
+    @Test
+    public void testShiftRangeNoElemChar() {
+        char[] array = new char[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1, 1, 1);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+    }
+
+    @Test
+    public void testShiftAllChar() {
+        char[] array = new char[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 4);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+        ArrayUtils.shift(array, -4);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+    }
+    
+    @Test
+    public void testShiftLong() {
+        long[] array = new long[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1);
+        assertEquals(4, array[0]);
+        assertEquals(1, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(3, array[3]);
+        ArrayUtils.shift(array, -1);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+        ArrayUtils.shift(array, 5);
+        assertEquals(4, array[0]);
+        assertEquals(1, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(3, array[3]);
+        ArrayUtils.shift(array, -3);
+        assertEquals(3, array[0]);
+        assertEquals(4, array[1]);
+        assertEquals(1, array[2]);
+        assertEquals(2, array[3]);
+    }
+
+    @Test
+    public void testShiftRangeLong() {
+        long[] array = new long[] {1, 2, 3, 4, 5};
+        ArrayUtils.shift(array, 1, 3, 1);
+        assertEquals(1, array[0]);
+        assertEquals(3, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(4, array[3]);
+        assertEquals(5, array[4]);
+        ArrayUtils.shift(array, 1, 4, 2);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(4, array[2]);
+        assertEquals(3, array[3]);
+        assertEquals(5, array[4]);
+    }
+
+    @Test
+    public void testShiftRangeNoElemLong() {
+        long[] array = new long[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1, 1, 1);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+    }
+
+    @Test
+    public void testShiftAllLong() {
+        long[] array = new long[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 4);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+        ArrayUtils.shift(array, -4);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+    }
+    
+    @Test
+    public void testShiftInt() {
+        int[] array = new int[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1);
+        assertEquals(4, array[0]);
+        assertEquals(1, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(3, array[3]);
+        ArrayUtils.shift(array, -1);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+        ArrayUtils.shift(array, 5);
+        assertEquals(4, array[0]);
+        assertEquals(1, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(3, array[3]);
+        ArrayUtils.shift(array, -3);
+        assertEquals(3, array[0]);
+        assertEquals(4, array[1]);
+        assertEquals(1, array[2]);
+        assertEquals(2, array[3]);
+    }
+
+    @Test
+    public void testShiftRangeInt() {
+        int[] array = new int[] {1, 2, 3, 4, 5};
+        ArrayUtils.shift(array, 1, 3, 1);
+        assertEquals(1, array[0]);
+        assertEquals(3, array[1]);
+        assertEquals(2, array[2]);
+        assertEquals(4, array[3]);
+        assertEquals(5, array[4]);
+        ArrayUtils.shift(array, 1, 4, 2);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(4, array[2]);
+        assertEquals(3, array[3]);
+        assertEquals(5, array[4]);
+    }
+
+    @Test
+    public void testShiftRangeNoElemInt() {
+        int[] array = new int[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 1, 1, 1);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+    }
+
+    @Test
+    public void testShiftAllInt() {
+        int[] array = new int[] {1, 2, 3, 4};
+        ArrayUtils.shift(array, 4);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+        ArrayUtils.shift(array, -4);
+        assertEquals(1, array[0]);
+        assertEquals(2, array[1]);
+        assertEquals(3, array[2]);
+        assertEquals(4, array[3]);
+    }
+
+    @Test
+    public void testShiftObject() {
+        String[] array = new String[] {"1", "2", "3", "4"};
+        ArrayUtils.shift(array, 1);
+        assertEquals("4", array[0]);
+        assertEquals("1", array[1]);
+        assertEquals("2", array[2]);
+        assertEquals("3", array[3]);
+        ArrayUtils.shift(array, -1);
+        assertEquals("1", array[0]);
+        assertEquals("2", array[1]);
+        assertEquals("3", array[2]);
+        assertEquals("4", array[3]);
+        ArrayUtils.shift(array, 5);
+        assertEquals("4", array[0]);
+        assertEquals("1", array[1]);
+        assertEquals("2", array[2]);
+        assertEquals("3", array[3]);
+        ArrayUtils.shift(array, -3);
+        assertEquals("3", array[0]);
+        assertEquals("4", array[1]);
+        assertEquals("1", array[2]);
+        assertEquals("2", array[3]);
+    }
+
+    @Test
+    public void testShiftRangeObject() {
+        String[] array = new String[] {"1", "2", "3", "4", "5"};
+        ArrayUtils.shift(array, 1, 3, 1);
+        assertEquals("1", array[0]);
+        assertEquals("3", array[1]);
+        assertEquals("2", array[2]);
+        assertEquals("4", array[3]);
+        assertEquals("5", array[4]);
+        ArrayUtils.shift(array, 1, 4, 2);
+        assertEquals("1", array[0]);
+        assertEquals("2", array[1]);
+        assertEquals("4", array[2]);
+        assertEquals("3", array[3]);
+        assertEquals("5", array[4]);
+    }
+
+    @Test
+    public void testShiftRangeNoElemObject() {
+        String[] array = new String[] {"1", "2", "3", "4"};
+        ArrayUtils.shift(array, 1, 1, 1);
+        assertEquals("1", array[0]);
+        assertEquals("2", array[1]);
+        assertEquals("3", array[2]);
+        assertEquals("4", array[3]);
+    }
+
+    @Test
+    public void testShiftAllObject() {
+        String[] array = new String[] {"1", "2", "3", "4"};
+        ArrayUtils.shift(array, 4);
+        assertEquals("1", array[0]);
+        assertEquals("2", array[1]);
+        assertEquals("3", array[2]);
+        assertEquals("4", array[3]);
+        ArrayUtils.shift(array, -4);
+        assertEquals("1", array[0]);
+        assertEquals("2", array[1]);
+        assertEquals("3", array[2]);
+        assertEquals("4", array[3]);
+    }
+    
     //-----------------------------------------------------------------------
     @Test
     public void testIndexOf() {


[5/7] [lang] testSwapIntExchangedOffsets

Posted by br...@apache.org.
testSwapIntExchangedOffsets

Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/af8d0ab9
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/af8d0ab9
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/af8d0ab9

Branch: refs/heads/master
Commit: af8d0ab9bcd092b3681376b30b56f8e8faacf3c2
Parents: c1501a2
Author: beradrian <be...@yahoo.com>
Authored: Tue Mar 24 12:49:19 2015 +0200
Committer: beradrian <be...@yahoo.com>
Committed: Tue Apr 28 12:58:13 2015 +0300

----------------------------------------------------------------------
 .../org/apache/commons/lang3/ArrayUtilsTest.java  | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/af8d0ab9/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
index 5633c9d..be3e119 100644
--- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java
@@ -2134,12 +2134,6 @@ public class ArrayUtilsTest  {
         assertArrayEquals(new char[] {2, 1, 3}, array);
     }
     
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testSwapCharOutOfBounds() {
-        char[] array = new char[] {1, 2, 3};
-        ArrayUtils.swap(array, 0, 5);
-    }
-
     @Test
     public void testSwapCharRange() {
         char[] array = new char[] {1, 2, 3, 4};
@@ -2242,6 +2236,18 @@ public class ArrayUtilsTest  {
         assertEquals(1, array[2]);
         assertEquals(2, array[3]);
     }
+    
+    @Test
+    public void testSwapIntExchangedOffsets() {
+        int[] array;
+        array = new int[] {1, 2, 3};
+        ArrayUtils.swap(array, 0, 1, 2);
+        assertArrayEquals(new int[] {2, 3, 1}, array);
+        
+        array = new int[] {1, 2, 3};
+        ArrayUtils.swap(array, 1, 0, 2);
+        assertArrayEquals(new int[] {2, 3, 1}, array);
+    }
 
     @Test(expected = ArrayIndexOutOfBoundsException.class)
     public void testSwapIntOutOfRange() {


[7/7] [lang] Merge branch 'array-utils'

Posted by br...@apache.org.
Merge branch 'array-utils'

LANG-1099: Add swap and shift operations for arrays to ArrayUtils. Thanks
to Adrian Ber.


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/fd680a65
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/fd680a65
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/fd680a65

Branch: refs/heads/master
Commit: fd680a65117e15f814a390253113ac51b165886f
Parents: 63d8a02 28a0672
Author: Benedikt Ritter <br...@apache.org>
Authored: Tue Apr 28 21:13:08 2015 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Tue Apr 28 21:13:08 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                         |    1 +
 .../org/apache/commons/lang3/ArrayUtils.java    | 1169 ++++++++++++++++++
 .../apache/commons/lang3/ArrayUtilsTest.java    |  741 +++++++++++
 3 files changed, 1911 insertions(+)
----------------------------------------------------------------------



[4/7] [lang] fix comments

Posted by br...@apache.org.
fix comments

Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/61095ef2
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/61095ef2
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/61095ef2

Branch: refs/heads/master
Commit: 61095ef28e4c1f8c1be7f97ff7d195de94bce4d9
Parents: 06506ae
Author: beradrian <be...@yahoo.com>
Authored: Mon Mar 23 16:32:28 2015 +0200
Committer: beradrian <be...@yahoo.com>
Committed: Tue Apr 28 12:58:12 2015 +0300

----------------------------------------------------------------------
 .../org/apache/commons/lang3/ArrayUtils.java    | 36 ++++++++++----------
 1 file changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/61095ef2/src/main/java/org/apache/commons/lang3/ArrayUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
index fb53bf8..881ba63 100644
--- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
@@ -1858,7 +1858,7 @@ public class ArrayUtils {
      *
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
-     * @param offset1 the index of the second element to swap
+     * @param offset2 the index of the second element to swap
      * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
      */
     public static void swap(final Object[] array, int offset1, int offset2) {
@@ -1875,7 +1875,7 @@ public class ArrayUtils {
      *
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
-     * @param offset1 the index of the second element to swap
+     * @param offset2 the index of the second element to swap
      * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
      */
     public static void swap(final long[] array, int offset1, int offset2) {
@@ -1892,7 +1892,7 @@ public class ArrayUtils {
      *
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
-     * @param offset1 the index of the second element to swap
+     * @param offset2 the index of the second element to swap
      * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
      */
     public static void swap(final int[] array, int offset1, int offset2) {
@@ -1909,7 +1909,7 @@ public class ArrayUtils {
      *
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
-     * @param offset1 the index of the second element to swap
+     * @param offset2 the index of the second element to swap
      * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
      */
     public static void swap(final short[] array, int offset1, int offset2) {
@@ -1926,7 +1926,7 @@ public class ArrayUtils {
      *
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
-     * @param offset1 the index of the second element to swap
+     * @param offset2 the index of the second element to swap
      * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
      */
     public static void swap(final char[] array, int offset1, int offset2) {
@@ -1943,7 +1943,7 @@ public class ArrayUtils {
      *
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
-     * @param offset1 the index of the second element to swap
+     * @param offset2 the index of the second element to swap
      * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
      */
     public static void swap(final byte[] array, int offset1, int offset2) {
@@ -1960,7 +1960,7 @@ public class ArrayUtils {
      *
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
-     * @param offset1 the index of the second element to swap
+     * @param offset2 the index of the second element to swap
      * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
      */
     public static void swap(final double[] array, int offset1, int offset2) {
@@ -1977,7 +1977,7 @@ public class ArrayUtils {
      *
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
-     * @param offset1 the index of the second element to swap
+     * @param offset2 the index of the second element to swap
      * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
      */
     public static void swap(final float[] array, int offset1, int offset2) {
@@ -1994,7 +1994,7 @@ public class ArrayUtils {
      *
      * @param array  the array to swap, may be {@code null}
      * @param offset1 the index of the first element to swap
-     * @param offset1 the index of the second element to swap
+     * @param offset2 the index of the second element to swap
      * @throws ArrayIndexOutOfBoundsException if one of the indices is out of range
      */
     public static void swap(final boolean[] array, int offset1, int offset2) {
@@ -2011,7 +2011,7 @@ public class ArrayUtils {
      * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
-     * @param offset1 the index of the second element in the series to swap
+     * @param offset2 the index of the second element in the series to swap
      * @param len the number of elements to swap starting with the given indices
      * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
      */
@@ -2033,7 +2033,7 @@ public class ArrayUtils {
      * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
-     * @param offset1 the index of the second element in the series to swap
+     * @param offset2 the index of the second element in the series to swap
      * @param len the number of elements to swap starting with the given indices
      * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
      */
@@ -2056,7 +2056,7 @@ public class ArrayUtils {
      * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
-     * @param offset1 the index of the second element in the series to swap
+     * @param offset2 the index of the second element in the series to swap
      * @param len the number of elements to swap starting with the given indices
      * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
      */
@@ -2078,7 +2078,7 @@ public class ArrayUtils {
      * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
-     * @param offset1 the index of the second element in the series to swap
+     * @param offset2 the index of the second element in the series to swap
      * @param len the number of elements to swap starting with the given indices
      * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
      */
@@ -2100,7 +2100,7 @@ public class ArrayUtils {
      * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
-     * @param offset1 the index of the second element in the series to swap
+     * @param offset2 the index of the second element in the series to swap
      * @param len the number of elements to swap starting with the given indices
      * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
      */
@@ -2122,7 +2122,7 @@ public class ArrayUtils {
      * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
-     * @param offset1 the index of the second element in the series to swap
+     * @param offset2 the index of the second element in the series to swap
      * @param len the number of elements to swap starting with the given indices
      * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
      */
@@ -2144,7 +2144,7 @@ public class ArrayUtils {
      * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
-     * @param offset1 the index of the second element in the series to swap
+     * @param offset2 the index of the second element in the series to swap
      * @param len the number of elements to swap starting with the given indices
      * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
      */
@@ -2166,7 +2166,7 @@ public class ArrayUtils {
      * 
      * @param array the array to swap, may be {@code null}
      * @param offset1 the index of the first element in the series to swap
-     * @param offset1 the index of the second element in the series to swap
+     * @param offset2 the index of the second element in the series to swap
      * @param len the number of elements to swap starting with the given indices
      * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
      */
@@ -2188,7 +2188,7 @@ public class ArrayUtils {
     * 
     * @param array the array to swap, may be {@code null}
     * @param offset1 the index of the first element in the series to swap
-    * @param offset1 the index of the second element in the series to swap
+    * @param offset2 the index of the second element in the series to swap
     * @param len the number of elements to swap starting with the given indices
     * @throws ArrayIndexOutOfBoundsException if one of the indices (plus the length of the series to swap) is out of range
     */