All Downloads are FREE. Search and download functionalities are using the official Maven repository.

VCollections.src.org.violetlib.collections.FindVisitor Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2023 Alan Snyder.
 * All rights reserved.
 *
 * You may not use, copy or modify this file, except in compliance with the license agreement. For details see
 * accompanying license terms.
 */

package org.violetlib.collections;

import org.violetlib.collections.impl.ListImplSupport;

import org.jetbrains.annotations.*;

/**
  A visitor of elements in a collection that can short-circuit the iteration by returning a (non-null) result.

  @param  The type of the elements.

  @param  The type of the value returned by the visitor.
*/

public interface FindVisitor
{
    /**
      Return a find visitor that calls an indexed find visitor.
      The indexed find visitor receives indexes in increasing order.
    */

    static  @NotNull FindVisitor fromIndexedFindVisitor(@NotNull IndexedFindVisitor v)
    {
        return ListImplSupport.fromIndexedFindVisitor(v);
    }

    @Nullable R visit(@NotNull E element);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy