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,CAAC,SAAS,CAAC,yBAAyB,GAAG,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,wBAAwB,GAAI,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,SAAS,GAAmB,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,eAAe,GAAa,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,oBAAoB,GAAQ,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,oBAAoB,GAAQ,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,mBAAmB,GAAS,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,YAAY,GAAgB,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,SAAS,GAAmB,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,WAAW,GAAiB,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,UAAU,GAAkB,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,eAAe,GAAa,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,gBAAgB,GAAY,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,eAAe,GAAa,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,aAAa,GAAe,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,oBAAoB,GAAQ,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,sBAAsB,GAAM,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,kBAAkB,GAAU,YAAY,CAAC;AAClE,cAAc,CAAC,SAAS,CAAC,QAAQ,GAAoB,YAAY,CAAC;AAElE,cAAc;AACd,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC","file":"indexof.js","sourcesContent":["// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements.  See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership.  The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License.  You may obtain a copy of the License at\n//\n//   http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied.  See the License for the\n// specific language governing permissions and limitations\n// under the License.\n\nimport { Data } from '../data';\nimport { Type } from '../enum';\nimport { Visitor } from '../visitor';\nimport { VectorType } from '../interfaces';\nimport { getBool, iterateBits } from '../util/bit';\nimport { createElementComparator } from '../util/vector';\nimport {\n    DataType, Dictionary,\n    Bool, Null, Utf8, Binary, Decimal, FixedSizeBinary, List, FixedSizeList, Map_, Struct,\n    Float, Float16, Float32, Float64,\n    Int, Uint8, Uint16, Uint32, Uint64, Int8, Int16, Int32, Int64,\n    Date_, DateDay, DateMillisecond,\n    Interval, IntervalDayTime, IntervalYearMonth,\n    Time, TimeSecond, TimeMillisecond, TimeMicrosecond, TimeNanosecond,\n    Timestamp, TimestampSecond, TimestampMillisecond, TimestampMicrosecond, TimestampNanosecond,\n    Union, DenseUnion, SparseUnion,\n} from '../type';\n\n/** @ignore */\nexport interface IndexOfVisitor extends Visitor {\n    visit<T extends VectorType>  (node: T, value: T['TValue'] | null, index?: number): number;\n    visitMany <T extends VectorType>  (nodes: T[], values: (T['TValue'] | null)[], indices: (number | undefined)[]): number[];\n    getVisitFn<T extends Type>    (node: T): (vector: VectorType<T>, value: VectorType<T>['TValue'] | null, index?: number) => number;\n    getVisitFn<T extends DataType>(node: VectorType<T> | Data<T> | T): (vector: VectorType<T>, value:         T['TValue'] | null, index?: number) => number;\n    visitNull                 <T extends Null>                (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitBool                 <T extends Bool>                (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitInt                  <T extends Int>                 (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitInt8                 <T extends Int8>                (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitInt16                <T extends Int16>               (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitInt32                <T extends Int32>               (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitInt64                <T extends Int64>               (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitUint8                <T extends Uint8>               (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitUint16               <T extends Uint16>              (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitUint32               <T extends Uint32>              (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitUint64               <T extends Uint64>              (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitFloat                <T extends Float>               (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitFloat16              <T extends Float16>             (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitFloat32              <T extends Float32>             (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitFloat64              <T extends Float64>             (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitUtf8                 <T extends Utf8>                (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitBinary               <T extends Binary>              (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitFixedSizeBinary      <T extends FixedSizeBinary>     (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitDate                 <T extends Date_>               (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitDateDay              <T extends DateDay>             (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitDateMillisecond      <T extends DateMillisecond>     (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitTimestamp            <T extends Timestamp>           (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitTimestampSecond      <T extends TimestampSecond>     (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitTimestampMillisecond <T extends TimestampMillisecond>(vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitTimestampMicrosecond <T extends TimestampMicrosecond>(vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitTimestampNanosecond  <T extends TimestampNanosecond> (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitTime                 <T extends Time>                (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitTimeSecond           <T extends TimeSecond>          (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitTimeMillisecond      <T extends TimeMillisecond>     (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitTimeMicrosecond      <T extends TimeMicrosecond>     (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitTimeNanosecond       <T extends TimeNanosecond>      (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitDecimal              <T extends Decimal>             (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitList                 <T extends List>                (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitStruct               <T extends Struct>              (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitUnion                <T extends Union>               (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitDenseUnion           <T extends DenseUnion>          (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitSparseUnion          <T extends SparseUnion>         (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitDictionary           <T extends Dictionary>          (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitInterval             <T extends Interval>            (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitIntervalDayTime      <T extends IntervalDayTime>     (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitIntervalYearMonth    <T extends IntervalYearMonth>   (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitFixedSizeList        <T extends FixedSizeList>       (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n    visitMap                  <T extends Map_>                (vector: VectorType<T>, value: T['TValue'] | null, index?: number): number;\n}\n\n/** @ignore */\nexport class IndexOfVisitor extends Visitor {}\n\n/** @ignore */\nfunction nullIndexOf(vector: VectorType<Null>, searchElement?: null) {\n    // if you're looking for nulls and the vector isn't empty, we've got 'em!\n    return searchElement === null && vector.length > 0 ? 0 : -1;\n}\n\n/** @ignore */\nfunction indexOfNull<T extends DataType>(vector: VectorType<T>, fromIndex?: number): number {\n    const { nullBitmap } = vector;\n    if (!nullBitmap || vector.nullCount <= 0) {\n        return -1;\n    }\n    let i = 0;\n    for (const isValid of iterateBits(nullBitmap, vector.data.offset + (fromIndex || 0), vector.length, nullBitmap, getBool)) {\n        if (!isValid) { return i; }\n        ++i;\n    }\n    return -1;\n}\n\n/** @ignore */\nfunction indexOfValue<T extends DataType>(vector: VectorType<T>, searchElement?: T['TValue'] | null, fromIndex?: number): number {\n    if (searchElement === undefined) { return -1; }\n    if (searchElement === null) { return indexOfNull(vector, fromIndex); }\n    const compare = createElementComparator(searchElement);\n    for (let i = (fromIndex || 0) - 1, n = vector.length; ++i < n;) {\n        if (compare(vector.get(i))) {\n            return i;\n        }\n    }\n    return -1;\n}\n\n/** @ignore */\nfunction indexOfUnion<T extends DataType>(vector: VectorType<T>, searchElement?: T['TValue'] | null, fromIndex?: number): number {\n    // Unions are special -- they do have a nullBitmap, but so can their children.\n    // If the searchElement is null, we don't know whether it came from the Union's\n    // bitmap or one of its childrens'. So we don't interrogate the Union's bitmap,\n    // since that will report the wrong index if a child has a null before the Union.\n    const compare = createElementComparator(searchElement);\n    for (let i = (fromIndex || 0) - 1, n = vector.length; ++i < n;) {\n        if (compare(vector.get(i))) {\n            return i;\n        }\n    }\n    return -1;\n}\n\nIndexOfVisitor.prototype.visitNull                 =  nullIndexOf;\nIndexOfVisitor.prototype.visitBool                 = indexOfValue;\nIndexOfVisitor.prototype.visitInt                  = indexOfValue;\nIndexOfVisitor.prototype.visitInt8                 = indexOfValue;\nIndexOfVisitor.prototype.visitInt16                = indexOfValue;\nIndexOfVisitor.prototype.visitInt32                = indexOfValue;\nIndexOfVisitor.prototype.visitInt64                = indexOfValue;\nIndexOfVisitor.prototype.visitUint8                = indexOfValue;\nIndexOfVisitor.prototype.visitUint16               = indexOfValue;\nIndexOfVisitor.prototype.visitUint32               = indexOfValue;\nIndexOfVisitor.prototype.visitUint64               = indexOfValue;\nIndexOfVisitor.prototype.visitFloat                = indexOfValue;\nIndexOfVisitor.prototype.visitFloat16              = indexOfValue;\nIndexOfVisitor.prototype.visitFloat32              = indexOfValue;\nIndexOfVisitor.prototype.visitFloat64              = indexOfValue;\nIndexOfVisitor.prototype.visitUtf8                 = indexOfValue;\nIndexOfVisitor.prototype.visitBinary               = indexOfValue;\nIndexOfVisitor.prototype.visitFixedSizeBinary      = indexOfValue;\nIndexOfVisitor.prototype.visitDate                 = indexOfValue;\nIndexOfVisitor.prototype.visitDateDay              = indexOfValue;\nIndexOfVisitor.prototype.visitDateMillisecond      = indexOfValue;\nIndexOfVisitor.prototype.visitTimestamp            = indexOfValue;\nIndexOfVisitor.prototype.visitTimestampSecond      = indexOfValue;\nIndexOfVisitor.prototype.visitTimestampMillisecond = indexOfValue;\nIndexOfVisitor.prototype.visitTimestampMicrosecond = indexOfValue;\nIndexOfVisitor.prototype.visitTimestampNanosecond  = indexOfValue;\nIndexOfVisitor.prototype.visitTime                 = indexOfValue;\nIndexOfVisitor.prototype.visitTimeSecond           = indexOfValue;\nIndexOfVisitor.prototype.visitTimeMillisecond      = indexOfValue;\nIndexOfVisitor.prototype.visitTimeMicrosecond      = indexOfValue;\nIndexOfVisitor.prototype.visitTimeNanosecond       = indexOfValue;\nIndexOfVisitor.prototype.visitDecimal              = indexOfValue;\nIndexOfVisitor.prototype.visitList                 = indexOfValue;\nIndexOfVisitor.prototype.visitStruct               = indexOfValue;\nIndexOfVisitor.prototype.visitUnion                = indexOfValue;\nIndexOfVisitor.prototype.visitDenseUnion           = indexOfUnion;\nIndexOfVisitor.prototype.visitSparseUnion          = indexOfUnion;\nIndexOfVisitor.prototype.visitDictionary           = indexOfValue;\nIndexOfVisitor.prototype.visitInterval             = indexOfValue;\nIndexOfVisitor.prototype.visitIntervalDayTime      = indexOfValue;\nIndexOfVisitor.prototype.visitIntervalYearMonth    = indexOfValue;\nIndexOfVisitor.prototype.visitFixedSizeList        = indexOfValue;\nIndexOfVisitor.prototype.visitMap                  = indexOfValue;\n\n/** @ignore */\nexport const instance = new IndexOfVisitor();\n"]}