useDynLib(S4Vectors)

import(methods)
importFrom(utils, head, tail)
importFrom(stats, var, cov, cor, sd, median, quantile,
           smoothEnds, runmed, window, "window<-", aggregate,
           na.omit, na.exclude, complete.cases, setNames)
importFrom(stats4, summary, update)

import(BiocGenerics)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S4 classes
###

exportClasses(
    characterORNULL, vectorORfactor,
    DataTable,
    NSBS,
    Annotated,
    DataTableORNULL, Vector,
    Hits,
    Rle,
    List,
    SimpleList,
    DataFrame,
    expressionORfunction, FilterRules, FilterMatrix
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S3 methods
###

S3method(aggregate, Vector)
S3method(aggregate, Rle)
S3method(aggregate, List)

S3method(anyDuplicated, NSBS)
S3method(anyDuplicated, WindowNSBS)

S3method(as.data.frame, Vector)
S3method(as.data.frame, Rle)
S3method(as.data.frame, List)
S3method(as.data.frame, DataFrame)

S3method(as.list, Rle)
S3method(as.list, List)
S3method(as.list, SimpleList)

S3method(as.vector, Rle)

S3method(cbind, DataFrame)

S3method(diff, Rle)

S3method(droplevels, Rle)
S3method(droplevels, List)

S3method(duplicated, DataTable)
S3method(duplicated, Vector)
S3method(duplicated, Rle)

S3method(head, Vector)

S3method(levels, Rle)

S3method(mean, Rle)

S3method(median, Rle)

S3method(quantile, Rle)

S3method(rbind, DataFrame)

S3method(rev, Rle)

S3method(sort, Vector)
S3method(sort, Rle)

S3method(summary, Rle)

S3method(tail, Vector)

S3method(unique, DataTable)
S3method(unique, Vector)
S3method(unique, Rle)

S3method(window, Vector)

### We also export them thru the export() directive so that (a) they can be
### called directly, (b) tab-completion on the name of the generic shows them,
### and (c) methods() doesn't asterisk them.
export(
    aggregate.Vector,
    aggregate.Rle,
    aggregate.List,

    anyDuplicated.NSBS,
    anyDuplicated.WindowNSBS,

    as.data.frame.Vector,
    as.data.frame.Rle,
    as.data.frame.List,
    as.data.frame.DataFrame,

    as.list.Rle,
    as.list.List,
    as.list.SimpleList,

    as.vector.Rle,

    diff.Rle,

    droplevels.Rle,
    droplevels.List,

    duplicated.DataTable,
    duplicated.Vector,
    duplicated.Rle,

    head.Vector,

    levels.Rle,

    mean.Rle,

    median.Rle,

    quantile.Rle,

    rev.Rle,

    sort.Vector,
    sort.Rle,

    summary.Rle,

    tail.Vector,

    unique.DataTable,
    unique.Vector,
    unique.Rle,

    window.Vector
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S4 methods for generics not defined in S4Vectors
###

exportMethods(
    ## Methods for generics defined in the base package:
    length, names, "names<-",
    nrow, ncol, dim,
    NROW, NCOL,
    rownames, "rownames<-",
    colnames, "colnames<-",
    dimnames, "dimnames<-",
    is.na, anyNA,
    as.logical, as.integer, as.numeric, as.complex, as.character, as.raw,
    as.factor,
    as.list, as.data.frame,
    as.matrix, as.table,
    "[", "[<-",
    subset,
    c, append,
    merge,
    "==", "!=", "<=", ">=", "<", ">",
    match, duplicated, unique, anyDuplicated, "%in%",
    sort, rank, xtfrm,
    t,
    by,
    transform,
    substr, substring, levels, "levels<-", droplevels,
    "[[", "[[<-", "$", "$<-",
    split,
    eval, with, within,
    ifelse,  # Deprecated

    ## Methods for generics defined in the methods package:
    coerce, show,

    ## Methods for generics defined in the utils package:
    head, tail,

    ## Methods for generics defined in the stats package:
    window, aggregate, na.omit, na.exclude, complete.cases,

    ## Methods for generics defined in the stats4 package:
    summary,

    ## Methods for generics defined in the BiocGenerics package:
    cbind, rbind,
    lapply, sapply,
    Reduce, Filter, Find, Map, Position,
    unlist,
    do.call,
    union, intersect, setdiff,
    xtabs,
    start, end, width,
    grep, grepl
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export non-generic functions
###

export(
    ## S4-utils.R:
    setValidity2, new2, setMethods,

    ## utils.R:
    wmsg,
    .Call2,
    get_showHeadLines, get_showTailLines,
    printAtomicVectorInAGrid,

    ## normarg-utils.R:
    isTRUEorFALSE, isSingleInteger, isSingleNumber, isSingleString,
    isSingleNumberOrNA, isSingleStringOrNA,
    recycleIntegerArg, recycleNumericArg,
    recycleLogicalArg, recycleCharacterArg,
    recycleArg,
    fold,

    ## str-utils.R:
    safeExplode,
    strsplitAsListOfIntegerVectors,
    svn.time,

    ## subsetting-internals.R:
    normalizeSingleBracketSubscript,
    normalizeDoubleBracketSubscript,

    ## Hits-class.R:
    Hits,
    selectHits,
    remapHits,

    ## List-class.R:
    List, phead, ptail, pc,

    ## SimpleList-class.R:
    SimpleList,

    ## DataFrame-class.R:
    DataFrame,

    ## FilterRules-class.R:
    FilterRules, FilterMatrix
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S4 generics defined in S4Vectors + export corresponding methods
###

export(
    ## isSorted.R:
    isConstant, isSorted, isStrictlySorted,

    ## str-utils.R:
    unstrsplit,

    ## DataTable-class.R:
    ROWNAMES,
    as.env,

    ## subsetting-internals.R:
    NSBS,
    normalizeSingleBracketReplacementValue,
    extractROWS, replaceROWS,
    getListElement, setListElement,

    ## Annotated-class.R:
    metadata, "metadata<-",

    ## Vector-class.R:
    parallelSlotNames, parallelVectorNames,
    elementMetadata, mcols, values,
    "elementMetadata<-", "mcols<-", "values<-",
    rename,
    classNameForDisplay, showAsCell,

    ## Vector-comparison.R:
    compare,
    selfmatch,
    findMatches, countMatches,

    ## Hits-class.R:
    queryHits, subjectHits,
    queryLength, subjectLength,
    countQueryHits, countSubjectHits,

    ## Rle-class.R:
    runLength, "runLength<-", runValue, "runValue<-", nrun,
    Rle,
    findRun,
    shiftApply,

    ## Rle-utils.R:
    runsum, runmean, runwtsum, runq,

    ## List-class.R:
    elementType, elementLengths, lengths,
    isEmpty, revElements,

    ## List-utils.R:
    endoapply, mendoapply,

    ## FilterRules-class.R:
    active, "active<-", evalSeparately, subsetByFilter, params, filterRules
)

### Exactly the same list as above.
exportMethods(
    isConstant, isSorted, isStrictlySorted,
    unstrsplit,
    ROWNAMES,
    as.env,
    NSBS,
    normalizeSingleBracketReplacementValue,
    extractROWS, replaceROWS,
    getListElement, setListElement,
    metadata, "metadata<-",
    parallelVectorNames,
    elementMetadata, mcols, values,
    "elementMetadata<-", "mcols<-", "values<-",
    rename,
    classNameForDisplay, showAsCell,
    compare,
    selfmatch,
    findMatches, countMatches,
    queryHits, subjectHits,
    queryLength, subjectLength,
    countQueryHits, countSubjectHits,
    runLength, "runLength<-", runValue, "runValue<-", nrun,
    Rle,
    findRun,
    shiftApply,
    runsum, runmean, runwtsum, runq,
    elementType, elementLengths, lengths,
    isEmpty, revElements,
    endoapply, mendoapply,
    active, "active<-", evalSeparately, subsetByFilter, params, filterRules
)

