The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
/* Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

parcel Lucy;

/** An offset, a length, and a weight.
 *
 * Span objects store information about a span across an array of...
 * something. The unit is context-dependent.
 *
 * Text is one possibility, in which case offset and length might be measured
 * in Unicode code points.  However, the Span could also refer to a span
 * within an array of tokens, for example -- in which case the start and
 * offset might be measured in token positions.
 */
public class Lucy::Search::Span inherits Clownfish::Obj {

    int32_t offset;
    int32_t length;
    float   weight;

    /** Create a new Span.
     *
     * @param offset Integer offset, unit is context-dependent.
     * @param length Integer length, unit is context-dependent.
     * @param weight A floating point weight.
     */
    public inert incremented Span*
    new(int32_t offset, int32_t length, float weight = 0.0);

    /** Initialize a Span.  See [](.new) for a description of the
     * parameters.
     */
    public inert Span*
    init(Span *self, int32_t offset, int32_t length,
         float weight = 0.0);

    /** Accessor for `offset` attribute.
     */
    public int32_t
    Get_Offset(Span *self);

    /** Setter for `offset` attribute.
     */
    public void
    Set_Offset(Span *self, int32_t offset);

    /** Accessor for `length` attribute.
     */
    public int32_t
    Get_Length(Span *self);

    /** Setter for `length` attribute.
     */
    public void
    Set_Length(Span *self, int32_t length);

    /** Accessor for `weight` attribute.
     */
    public float
    Get_Weight(Span *self);

    /** Setter for `weight` attribute.
     */
    public void
    Set_Weight(Span *self, float weight);

    public bool
    Equals(Span *self, Obj *other);

    public int32_t
    Compare_To(Span *self, Obj *other);
}