Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–311 unchanged (311 lines)
312 * @throws IndexOutOfBoundsException if <code>index</code> is not within
313 * the specified range.
314 */
315 public void removeValue(int index) {
316 this.keys.remove(index);
317 this.values.remove(index);
318 if (index < this.keys.size()) {
319 rebuildIndex();
320 }
321 }
322
323 /**
324 * Removes a value from the collection.
325 *
326 * @param key the item key (<code>null</code> not permitted).
327 *
328 * @throws IllegalArgumentException if <code>key</code> is
329 * <code>null</code>.
330 * @throws UnknownKeyException if <code>key</code> is not recognised.
331 */
332 public void removeValue(Comparable key) {
333 int index = getIndex(key);
334 if (index < 0) {
335 return;
336 }
337 removeValue(index);
338 }
339
340 /**
341 * Clears all values from the collection.
…lines 342–471 unchanged (130 lines)

After

…lines 1–311 unchanged (311 lines)
312 * @throws IndexOutOfBoundsException if <code>index</code> is not within
313 * the specified range.
314 */
315 public void removeValue(int index) {
316 this.keys.remove(index);
317 this.values.remove(index);
318 rebuildIndex();
319 }
320
321 /**
322 * Removes a value from the collection.
323 *
324 * @param key the item key (<code>null</code> not permitted).
325 *
326 * @throws IllegalArgumentException if <code>key</code> is
327 * <code>null</code>.
328 * @throws UnknownKeyException if <code>key</code> is not recognised.
329 */
330 public void removeValue(Comparable key) {
331 int index = getIndex(key);
332 if (index < 0) {
333 throw new UnknownKeyException("The key (" + key
334 + ") is not recognised.");
335 }
336 removeValue(index);
337 }
338
339 /**
340 * Clears all values from the collection.
…lines 341–470 unchanged (130 lines)

Before

program
block_comment "/* ========================================================="...
package_declaration
package "package"
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jfree"
. "."
identifier "data"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "Serializable"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "ArrayList"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Arrays"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Comparator"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashMap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jfree"
. "."
identifier "chart"
. "."
identifier "util"
. "."
identifier "PublicCloneable"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jfree"
. "."
identifier "chart"
. "."
identifier "util"
. "."
identifier "SortOrder"
; ";"
block_comment "/**\n * An ordered list of (key, value) items. This class pr"...
class_declaration
modifiers
public "public"
class "class"
identifier "DefaultKeyedValues"
super_interfaces
implements "implements"
type_list
type_identifier "KeyedValues"
, ","
type_identifier "Cloneable"
, ","
type_identifier "PublicCloneable"
, ","
type_identifier "Serializable"
class_body
{ "{"
block_comment "/** For serialization. */"
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
long "long"
variable_declarator
identifier "serialVersionUID"
= "="
decimal_integer_literal "8468154364608194797L"
; ";"
block_comment "/** Storage for the keys. */"
field_declaration
modifiers
private "private"
type_identifier "ArrayList"
variable_declarator
identifier "keys"
; ";"
block_comment "/** Storage for the values. */"
field_declaration
modifiers
private "private"
type_identifier "ArrayList"
variable_declarator
identifier "values"
; ";"
block_comment "/** \n * Contains (key, Integer) mappings, where the Inte"...
field_declaration
modifiers
private "private"
type_identifier "HashMap"
variable_declarator
identifier "indexMap"
; ";"
block_comment "/**\n * Creates a new collection (initially empty).\n "...
constructor_declaration (+52 nodes collapsed)
block_comment "/**\n * Returns the number of items (values) in the colle"...
method_declaration (+25 nodes collapsed)
block_comment "/**\n * Returns a value.\n *\n * @param item the i"...
method_declaration (+33 nodes collapsed)
block_comment "/**\n * Returns a key.\n *\n * @param index the it"...
method_declaration (+33 nodes collapsed)
block_comment "/**\n * Returns the index for a given key.\n *\n * "...
method_declaration (+92 nodes collapsed)
block_comment "/**\n * Returns the keys for the values in the collection"...
method_declaration (+28 nodes collapsed)
block_comment "/**\n * Returns the value for a given key.\n *\n * "...
method_declaration (+64 nodes collapsed)
block_comment "/**\n * Updates an existing value, or adds a new value to"...
method_declaration (+35 nodes collapsed)
block_comment "/**\n * Adds a new value to the collection, or updates an"...
method_declaration (+28 nodes collapsed)
block_comment "/**\n * Updates an existing value, or adds a new value to"...
method_declaration (+35 nodes collapsed)
block_comment "/**\n * Updates an existing value, or adds a new value to"...
method_declaration (+161 nodes collapsed)
block_comment "/**\n * Inserts a new value at the specified position in "...
method_declaration (+42 nodes collapsed)
block_comment "/**\n * Inserts a new value at the specified position in "...
method_declaration (+217 nodes collapsed)
block_comment "/**\n * Rebuilds the key to indexed-position mapping afte"...
method_declaration (+95 nodes collapsed)
block_comment "/**\n * Removes a value from the collection.\n *\n "...
method_declaration
modifiers
public "public"
void_type "void"
identifier "removeValue"
formal_parameters
( "("
formal_parameter
integral_type
int "int"
identifier "index"
) ")"
block
{ "{"
expression_statement
method_invocation
field_access
this "this"
. "."
identifier "keys"
. "."
identifier "remove"
argument_list
( "("
identifier "index"
) ")"
; ";"
expression_statement
method_invocation
field_access
this "this"
. "."
identifier "values"
. "."
identifier "remove"
argument_list
( "("
identifier "index"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "index"
< "<"
method_invocation
field_access
this "this"
. "."
identifier "keys"
. "."
identifier "size"
argument_list
( "("
) ")"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "rebuildIndex"
argument_list
( "("
) ")"
; ";"
} "}"
} "}"
block_comment "/**\n * Removes a value from the collection.\n *\n "...
method_declaration
modifiers
public "public"
void_type "void"
identifier "removeValue"
formal_parameters
( "("
formal_parameter
type_identifier "Comparable"
identifier "key"
) ")"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "index"
= "="
method_invocation
identifier "getIndex"
argument_list
( "("
identifier "key"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "index"
< "<"
decimal_integer_literal "0"
) ")"
block
{ "{"
return_statement
return "return"
; ";"
} "}"
expression_statement
method_invocation
identifier "removeValue"
argument_list
( "("
identifier "index"
) ")"
; ";"
} "}"
block_comment "/**\n * Clears all values from the collection.\n * \n "...
method_declaration (+47 nodes collapsed)
block_comment "/**\n * Sorts the items in the list by key.\n *\n *"...
method_declaration (+219 nodes collapsed)
block_comment "/**\n * Sorts the items in the list by value. If the lis"...
method_declaration (+219 nodes collapsed)
block_comment "/**\n * Tests if this object is equal to another.\n *\n"...
method_declaration (+251 nodes collapsed)
block_comment "/**\n * Returns a hash code.\n * \n * @return A has"...
method_declaration (+39 nodes collapsed)
block_comment "/**\n * Returns a clone.\n * \n * @return A clone.\n"...
method_declaration (+101 nodes collapsed)
} "}"

After

program
block_comment "/* ========================================================="...
package_declaration
package "package"
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jfree"
. "."
identifier "data"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "Serializable"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "ArrayList"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Arrays"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Comparator"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashMap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jfree"
. "."
identifier "chart"
. "."
identifier "util"
. "."
identifier "PublicCloneable"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jfree"
. "."
identifier "chart"
. "."
identifier "util"
. "."
identifier "SortOrder"
; ";"
block_comment "/**\n * An ordered list of (key, value) items. This class pr"...
class_declaration
modifiers
public "public"
class "class"
identifier "DefaultKeyedValues"
super_interfaces
implements "implements"
type_list
type_identifier "KeyedValues"
, ","
type_identifier "Cloneable"
, ","
type_identifier "PublicCloneable"
, ","
type_identifier "Serializable"
class_body
{ "{"
block_comment "/** For serialization. */"
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
long "long"
variable_declarator
identifier "serialVersionUID"
= "="
decimal_integer_literal "8468154364608194797L"
; ";"
block_comment "/** Storage for the keys. */"
field_declaration
modifiers
private "private"
type_identifier "ArrayList"
variable_declarator
identifier "keys"
; ";"
block_comment "/** Storage for the values. */"
field_declaration
modifiers
private "private"
type_identifier "ArrayList"
variable_declarator
identifier "values"
; ";"
block_comment "/** \n * Contains (key, Integer) mappings, where the Inte"...
field_declaration
modifiers
private "private"
type_identifier "HashMap"
variable_declarator
identifier "indexMap"
; ";"
block_comment "/**\n * Creates a new collection (initially empty).\n "...
constructor_declaration (+52 nodes collapsed)
block_comment "/**\n * Returns the number of items (values) in the colle"...
method_declaration (+25 nodes collapsed)
block_comment "/**\n * Returns a value.\n *\n * @param item the i"...
method_declaration (+33 nodes collapsed)
block_comment "/**\n * Returns a key.\n *\n * @param index the it"...
method_declaration (+33 nodes collapsed)
block_comment "/**\n * Returns the index for a given key.\n *\n * "...
method_declaration (+92 nodes collapsed)
block_comment "/**\n * Returns the keys for the values in the collection"...
method_declaration (+28 nodes collapsed)
block_comment "/**\n * Returns the value for a given key.\n *\n * "...
method_declaration (+64 nodes collapsed)
block_comment "/**\n * Updates an existing value, or adds a new value to"...
method_declaration (+35 nodes collapsed)
block_comment "/**\n * Adds a new value to the collection, or updates an"...
method_declaration (+28 nodes collapsed)
block_comment "/**\n * Updates an existing value, or adds a new value to"...
method_declaration (+35 nodes collapsed)
block_comment "/**\n * Updates an existing value, or adds a new value to"...
method_declaration (+161 nodes collapsed)
block_comment "/**\n * Inserts a new value at the specified position in "...
method_declaration (+42 nodes collapsed)
block_comment "/**\n * Inserts a new value at the specified position in "...
method_declaration (+217 nodes collapsed)
block_comment "/**\n * Rebuilds the key to indexed-position mapping afte"...
method_declaration (+95 nodes collapsed)
block_comment "/**\n * Removes a value from the collection.\n *\n "...
method_declaration
modifiers
public "public"
void_type "void"
identifier "removeValue"
formal_parameters
( "("
formal_parameter
integral_type
int "int"
identifier "index"
) ")"
block
{ "{"
expression_statement
method_invocation
field_access
this "this"
. "."
identifier "keys"
. "."
identifier "remove"
argument_list
( "("
identifier "index"
) ")"
; ";"
expression_statement
method_invocation
field_access
this "this"
. "."
identifier "values"
. "."
identifier "remove"
argument_list
( "("
identifier "index"
) ")"
; ";"
expression_statement
method_invocation
identifier "rebuildIndex"
argument_list
( "("
) ")"
; ";"
} "}"
block_comment "/**\n * Removes a value from the collection.\n *\n "...
method_declaration
modifiers
public "public"
void_type "void"
identifier "removeValue"
formal_parameters
( "("
formal_parameter
type_identifier "Comparable"
identifier "key"
) ")"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "index"
= "="
method_invocation
identifier "getIndex"
argument_list
( "("
identifier "key"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "index"
< "<"
decimal_integer_literal "0"
) ")"
block
{ "{"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "UnknownKeyException"
argument_list
( "("
binary_expression
binary_expression
string_literal
" "\""
string_fragment "The key ("
" "\""
+ "+"
identifier "key"
+ "+"
string_literal
" "\""
string_fragment ") is not recognised."
" "\""
) ")"
; ";"
} "}"
expression_statement
method_invocation
identifier "removeValue"
argument_list
( "("
identifier "index"
) ")"
; ";"
} "}"
block_comment "/**\n * Clears all values from the collection.\n * \n "...
method_declaration (+47 nodes collapsed)
block_comment "/**\n * Sorts the items in the list by key.\n *\n *"...
method_declaration (+219 nodes collapsed)
block_comment "/**\n * Sorts the items in the list by value. If the lis"...
method_declaration (+219 nodes collapsed)
block_comment "/**\n * Tests if this object is equal to another.\n *\n"...
method_declaration (+251 nodes collapsed)
block_comment "/**\n * Returns a hash code.\n * \n * @return A has"...
method_declaration (+39 nodes collapsed)
block_comment "/**\n * Returns a clone.\n * \n * @return A clone.\n"...
method_declaration (+101 nodes collapsed)
} "}"