Java empty list size 1

Increasing subarray code in python. I want to get a subarray in python 3

  • Add the Codota plugin to your IDE and get smart completions

private void myMethod [] {

LocalDateTime l =

}

@Override List>> batch[List>[types.subList[index, index + size]]]; } if [batches.isEmpty[]] { return Collections.singletonList[types]; } else { batches.get[0].addAll[0, types.subList[0, reminder]]; return batches; } } } }

origin: dropwizard/dropwizard

private List getNonProxyHostPatterns[@Nullable List nonProxyHosts] { if [nonProxyHosts == null] { return Collections.emptyList[]; } final List patterns = new ArrayList[nonProxyHosts.size[]]; for [String nonProxyHost : nonProxyHosts] { // Replaces a wildcard to a regular expression patterns.add[Pattern.compile[WILDCARD.matcher[nonProxyHost].replaceAll[REGEX_WILDCARD]]]; } return Collections.unmodifiableList[patterns]; }

origin: spring-projects/spring-framework

@Override protected List getNonOptionArgs[] { List argValues = this.source.nonOptionArguments[]; List stringArgValues = new ArrayList[]; for [Object argValue : argValues] { stringArgValues.add[argValue.toString[]]; } return [stringArgValues.isEmpty[] ? Collections.emptyList[] : Collections.unmodifiableList[stringArgValues]]; }

origin: spring-projects/spring-framework

/** * Assert that the listener identified by the specified id has received the * specified events, in that specific order. */ public void assertEvent[String listenerId, Object... events] { List actual = this.content.getOrDefault[listenerId, Collections.emptyList[]]; assertEquals["Wrong number of events", events.length, actual.size[]]; for [int i = 0; i < events.length; i++] { assertEquals["Wrong event at index " + i, events[i], actual.get[i]]; } }

origin: spring-projects/spring-framework

@SuppressWarnings["unchecked"] static List getAdviceByType[@Nullable List requestResponseBodyAdvice, Class adviceType] { if [requestResponseBodyAdvice != null] { List result = new ArrayList[]; for [Object advice : requestResponseBodyAdvice] { Class beanType = [advice instanceof ControllerAdviceBean ? [[ControllerAdviceBean] advice].getBeanType[] : advice.getClass[]]; if [beanType != null && adviceType.isAssignableFrom[beanType]] { result.add[[T] advice]; } } return result; } return Collections.emptyList[]; }

@Test public void mergeBiFunction[] throws Exception { MergerBiFunction f = new MergerBiFunction[Functions.naturalComparator[]]; assertEquals[0, f.apply[Collections.emptyList[], Collections.emptyList[]].size[]]; assertEquals[Arrays.asList[1, 2], f.apply[Collections.emptyList[], Arrays.asList[1, 2]]]; for [int i = 0; i < 4; i++] { int k = 0; List list1 = new ArrayList[]; for [int j = 0; j < i; j++] { list1.add[k++]; } List list2 = new ArrayList[]; for [int j = i; j < 4; j++] { list2.add[k++]; } assertEquals[Arrays.asList[0, 1, 2, 3], f.apply[list1, list2]]; } }

origin: spring-projects/spring-framework

/** * Parse the given list of [potentially] comma-separated strings into a * list of {@code MediaType} objects. *

This method can be used to parse an Accept or Content-Type header. * @param mediaTypes the string to parse * @return the list of media types * @throws InvalidMediaTypeException if the media type value cannot be parsed * @since 4.3.2 */ public static List parseMediaTypes[@Nullable List mediaTypes] { if [CollectionUtils.isEmpty[mediaTypes]] { return Collections.emptyList[]; } else if [mediaTypes.size[] == 1] { return parseMediaTypes[mediaTypes.get[0]]; } else { List result = new ArrayList[8]; for [String mediaType : mediaTypes] { result.addAll[parseMediaTypes[mediaType]]; } return result; } }

public static List bitSetToBlocks[MethodNode mth, BitSet bs] { int size = bs.cardinality[]; if [size == 0] { return Collections.emptyList[]; } List blocks = new ArrayList[size]; for [int i = bs.nextSetBit[0]; i >= 0; i = bs.nextSetBit[i + 1]] { BlockNode block = mth.getBasicBlocks[].get[i]; blocks.add[block]; } return blocks; }

public void testPartition_empty[] { List source = Collections.emptyList[]; List partitions = Lists.partition[source, 1]; assertTrue[partitions.isEmpty[]]; assertEquals[0, partitions.size[]]; }

origin: spring-projects/spring-framework

@Test public void path[] throws Exception { // basic testPath["/a/b/c", "/a/b/c", Arrays.asList["/", "a", "/", "b", "/", "c"]]; // root path testPath["/", "/", Collections.singletonList["/"]]; // empty path testPath["", "", Collections.emptyList[]]; testPath["%20%20", "%20%20", Collections.singletonList["%20%20"]]; // trailing slash testPath["/a/b/", "/a/b/", Arrays.asList["/", "a", "/", "b", "/"]]; testPath["/a/b//", "/a/b//", Arrays.asList["/", "a", "/", "b", "/", "/"]]; // extra slashes and spaces testPath["/%20", "/%20", Arrays.asList["/", "%20"]]; testPath["//%20/%20", "//%20/%20", Arrays.asList["/", "/", "%20", "/", "%20"]]; }

origin: spring-projects/spring-framework

/** * Returns the value of the {@code Sec-WebSocket-Key} header. * @return the value of the header */ public List getSecWebSocketProtocol[] { List values = get[SEC_WEBSOCKET_PROTOCOL]; if [CollectionUtils.isEmpty[values]] { return Collections.emptyList[]; } else if [values.size[] == 1] { return getValuesAsList[SEC_WEBSOCKET_PROTOCOL]; } else { return values; } }

@SuppressWarnings["unchecked"] // dang varargs @Override Scenario mutate[Scenario scenario] { List words = Lists.newArrayList[]; words.add[Collections.emptyList[]]; for [T t : scenario.strictlyOrderedList] { words.add[Arrays.asList[t]]; for [T s : scenario.strictlyOrderedList] { words.add[Arrays.asList[t, s]]; } } return new Scenario[ scenario.ordering.lexicographical[], words, new Iterable[0]]; } },

origin: spring-projects/spring-framework

/** * Returns the value of the {@code Sec-WebSocket-Extensions} header. * @return the value of the header */ public List getSecWebSocketExtensions[] { List values = get[SEC_WEBSOCKET_EXTENSIONS]; if [CollectionUtils.isEmpty[values]] { return Collections.emptyList[]; } else { List result = new ArrayList[values.size[]]; for [String value : values] { result.addAll[WebSocketExtension.parseExtensions[value]]; } return result; } }

@Test public void request[] { TestResourceSubscriber tc = new TestResourceSubscriber[] { @Override protected void onStart[] { start++; } }; Flowable.just[1].subscribe[tc]; assertEquals[1, tc.start]; assertEquals[Collections.emptyList[], tc.values]; assertTrue[tc.errors.isEmpty[]]; assertEquals[0, tc.complete]; tc.requestMore[1]; assertEquals[1, tc.start]; assertEquals[1, tc.values.get[0].intValue[]]; assertTrue[tc.errors.isEmpty[]]; assertEquals[1, tc.complete]; }

public List getAllLoopsForBlock[BlockNode block] { if [loops.isEmpty[]] { return Collections.emptyList[]; } List list = new ArrayList[loops.size[]]; for [LoopInfo loop : loops] { if [loop.getLoopBlocks[].contains[block]] { list.add[loop]; } } return list; }

origin: jenkinsci/jenkins

private List get[Map map, AbstractProject src, boolean up] { List v = map.get[src]; if[v==null] return Collections.emptyList[]; List result = new ArrayList[v.size[]]; for [DependencyGroup d : v] result.add[up ? d.getUpstreamProject[] : d.getDownstreamProject[]]; return result; }

Video liên quan

Chủ Đề