Download the PHP package jrdev/drange without Composer

On this page you can find all versions of the php package jrdev/drange. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package drange

DRange

Tests Latest Version PHP License

DRange is a PHP library for managing discontinuous (non-contiguous) ranges of integers. Rather than storing every number individually, it holds a compact, sorted list of contiguous sub-ranges — automatically merging adjacent ranges when you add numbers and splitting them when you subtract. The result is an expressive, memory-efficient structure for any problem that involves gaps in sequences.

Features

Requirements

Installation

Quick Start

API Reference

DRange (jrdev\DRange)

Method / Usage Returns Description
new DRange() DRange Empty range
new DRange($n) DRange Range containing the single integer $n
new DRange($low, $high) DRange Contiguous range [$low..$high]
->add($n) $this Add a single integer
->add($low, $high) $this Add a contiguous range
->add($drange) $this Add all sub-ranges from another DRange
->add($subrange) $this Add a SubRange instance
->subtract($n) $this Subtract a single integer
->subtract($low, $high) $this Subtract a contiguous range
->subtract($drange) $this Subtract all sub-ranges of another DRange
->subtract($subrange) $this Subtract a SubRange instance
->intersect($n) DRange New range containing only integers present in both this range and $n
->intersect($low, $high) DRange Intersection with a contiguous range
->intersect($drange) DRange Intersection with another DRange
->intersect($subrange) DRange Intersection with a SubRange instance
->index($i) int\|null Value at logical position $i (0-based); null if out of bounds
count($drange) int Total number of integers across all sub-ranges
(string) $drange string e.g. "[ 1-5, 8-10 ]"
clone $drange DRange Deep copy; mutations do not affect the original

Adjacent ranges (touching but not overlapping) are merged automatically on every add() call.

SubRange (jrdev\DRange\SubRange)

Member Type Description
new SubRange($low, $high) Throws \UnexpectedValueException if $low > $high
->low int Lower bound (inclusive)
->high int Upper bound (inclusive)
->length int $high - $low + 1
->overlaps($range) bool true if the two ranges share at least one integer
->touches($range) bool true if the ranges overlap or are adjacent (no gap between them)
->add($range) SubRange Merged range — only meaningful when touches() is true
->subtract($range) SubRange[] Returns 0, 1, or 2 sub-ranges after removing the overlap
(string) $subrange string "low-high" or just "n" for a single-number range
clone $subrange SubRange Deep copy

Usage Examples

Method chaining

Operating on two DRange objects

Random access with index()

Counting with native count()

Computing intersections with intersect()

Using SubRange directly

Real-World Use Cases

License

Licensed under the MIT licence.


All versions of drange with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jrdev/drange contains the following files

Loading the files please wait ...