samujjwal / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Feature request: Add a JsonArray reverse method #606

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Can we get a JsonArray.reverse() function to simply reverse its backing List?

Right now I have to manually iterate through the JsonArray in reverse and add 
those elements to a new/temp JsonArray.

I noticed that in an old revision of the JsonArray.java class 
(https://code.google.com/p/google-gson/source/browse/trunk/gson/src/main/java/co
m/google/gson/JsonArray.java?r=486) there used to be a reverse() method, 
however it was package private:

  /**
   * Reverses the elements of the array.
   */
  void reverse() {
    Collections.reverse(elements);
  }

Can we reintroduce this method and make it public?

Original issue reported on code.google.com by theother...@gmail.com on 8 Nov 2014 at 8:48