MCPcopy Create free account
hub / github.com/antlr/codebuff / strip

Method strip

output/java8/1.4.16/Interpreter.java:1040–1053  ·  view source on GitHub ↗

Return a new list without null values.

(InstanceScope scope, Object v)

Source from the content-addressed store, hash-verified

1038 /** Return a new list without {@code null} values. */
1039
1040 public Object strip(InstanceScope scope, Object v) {
1041 if ( v==null ) return null;
1042 v = convertAnythingIteratableToIterator(scope, v);
1043 if ( v instanceof Iterator ) {
1044 List<Object> a = new ArrayList<Object>();
1045 Iterator<?> it = (Iterator<?>)v;
1046 while ( it.hasNext() ) {
1047 Object o = it.next();
1048 if ( o!=null ) a.add(o);
1049 }
1050 return a;
1051 }
1052 return v; // strip(x)==x when x single-valued attribute
1053 }
1054
1055 /**
1056 * Return a list with the same elements as {@code v} but in reverse order.

Callers 1

_execMethod · 0.95

Calls 4

nextMethod · 0.65
addMethod · 0.65
hasNextMethod · 0.45

Tested by

no test coverage detected