import(methods)
importFrom(stats, setNames,
                  dnorm, pnorm, qnorm,
                  dbinom, pbinom, qbinom,
                  dpois, ppois, qpois,
                  dlogis, plogis, qlogis)
importFrom(stats4, summary)
import(matrixStats)
import(BiocGenerics)
import(S4Vectors)
import(IRanges)
import(BiocParallel)


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

exportClasses(
    ## Array-class.R:
    Array,

    ## ArrayGrid-class.R:
    ArrayViewport, ArrayGrid, ArbitraryArrayGrid, RegularArrayGrid,

    ## extract_array.R:
    integer_OR_NULL,

    ## DelayedArray-class.R:
    DelayedArray, DelayedMatrix,

    ## realize.R:
    RealizationSink, arrayRealizationSink,

    ## RleArray-class.R:
    RleArraySeed, SolidRleArraySeed, RleRealizationSink, ChunkedRleArraySeed,
    RleArray, RleMatrix
)


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

S3method(aperm, DelayedArray)

S3method(as.array, Array)

S3method(as.character, Array)
S3method(as.character, ArrayGrid)

S3method(as.complex, Array)

S3method(as.data.frame, Array)

S3method(as.integer, Array)

S3method(as.logical, Array)

S3method(as.matrix, Array)

S3method(as.numeric, Array)

S3method(as.raw, Array)

S3method(as.vector, Array)

S3method(mean, DelayedArray)

S3method(split, DelayedArray)

S3method(summary, DelayedOp)
S3method(summary, DelayedSubset)
S3method(summary, DelayedAperm)
S3method(summary, DelayedUnaryIsoOp)
S3method(summary, DelayedDimnames)
S3method(summary, DelayedNaryIsoOp)
S3method(summary, DelayedAbind)

S3method(t, DelayedMatrix)

### 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(
    aperm.DelayedArray,

    as.array.Array,

    as.character.ArrayGrid,
    as.character.Array,

    as.complex.Array,

    as.data.frame.Array,

    as.integer.Array,

    as.logical.Array,

    as.matrix.Array,

    as.numeric.Array,

    as.raw.Array,

    as.vector.Array,

    mean.DelayedArray,

    split.DelayedArray,

    summary.DelayedOp,
    summary.DelayedSubset,
    summary.DelayedAperm,
    summary.DelayedUnaryIsoOp,
    summary.DelayedDimnames,
    summary.DelayedNaryIsoOp,
    summary.DelayedAbind,

    t.DelayedMatrix
)


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

exportMethods(
    ## Methods for generics defined in the base package:
    length, names, "names<-",
    dim, "dim<-", dimnames, "dimnames<-",
    "[", "[[", "[<-",
    lengths,
    as.array, as.matrix, as.data.frame, as.vector,
    as.logical, as.integer, as.numeric, as.complex, as.character, as.raw,
    c, split,
    drop, t,
    is.na, is.finite, is.infinite, is.nan,
    "!",
    #"+", "-", "*", "/", "^", "%%", "%/%",  # "Arith" group generic
    "==", "!=", "<=", ">=", "<", ">",       # "Compare" group generic
    sweep,
    anyNA, which,
    max, min, range, sum, prod, any, all,   # "Summary" group generic
    mean,
    round, signif,
    rowSums, colSums, rowMeans, colMeans,
    nchar, tolower, toupper,
    sub, gsub,

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

    ## Methods for generics defined in the stats package:
    dnorm, pnorm, qnorm,
    dbinom, pbinom, qbinom,
    dpois, ppois, qpois,
    dlogis, plogis, qlogis,

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

    ## Methods for generics defined in the BiocGenerics package:
    cbind, rbind,
    grepl,
    path, "path<-",
    updateObject,

    ## Methods for generics defined in the S4Vectors package:
    isEmpty,

    ## Methods for generics defined in the IRanges package:
    ranges, start, end, width,
    splitAsList
)


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

export(
    ## ArrayGrid-class.R:
    ArrayViewport, makeNindexFromArrayViewport,
    ArbitraryArrayGrid, RegularArrayGrid,

    ## showtree.R:
    showtree, contentIsPristine,

    ## DelayedArray-class.R:
    new_DelayedArray,

    ## realize.R:
    supportedRealizationBackends, getRealizationBackend, setRealizationBackend,

    ## block_processing.R:
    getDefaultBPPARAM, setDefaultBPPARAM,
    defaultGrid, blockApply, effectiveGrid, currentBlockId, currentViewport,
    write_array_to_sink,

    ## RleArray-class.R:
    RleArray
)


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

export(
    ## bind-arrays.R:
    arbind, acbind,

    ## ArrayGrid-class.R:
    refdim, isLinear,

    ## extract_array.R:
    extract_array, type, chunkdim,

    ## DelayedOp-class.R:
    isNoOp,

    ## showtree.R:
    simplify, netSubsetAndAperm,

    ## DelayedArray-class.R:
    matrixClass, DelayedArray, nseed, seed, "seed<-", aperm,

    ## realize.R:
    chunk_dim, write_block_to_sink, close,
    realize,

    ## DelayedArray-utils.R:
    pmax2, pmin2, apply,

    ## DelayedMatrix-stats.R:
    rowMaxs, colMaxs, rowMins, colMins, rowRanges, colRanges
)

### Exactly the same list as above.
exportMethods(
    arbind, acbind,
    refdim, isLinear,
    extract_array, type, chunkdim,
    isNoOp,
    simplify, netSubsetAndAperm,
    matrixClass, DelayedArray, nseed, seed, "seed<-", aperm,
    chunk_dim, write_block_to_sink, close,
    realize,
    pmax2, pmin2, apply,
    rowMaxs, colMaxs, rowMins, colMins, rowRanges, colRanges
)

