Blame src/bitSet.mli

rpm-build 0f2925
(*
rpm-build 0f2925
 * Bitset - Efficient bit sets
rpm-build 0f2925
 * Copyright (C) 2003 Nicolas Cannasse
rpm-build 0f2925
 *
rpm-build 0f2925
 * This library is free software; you can redistribute it and/or
rpm-build 0f2925
 * modify it under the terms of the GNU Lesser General Public
rpm-build 0f2925
 * License as published by the Free Software Foundation; either
rpm-build 0f2925
 * version 2.1 of the License, or (at your option) any later version,
rpm-build 0f2925
 * with the special exception on linking described in file LICENSE.
rpm-build 0f2925
 *
rpm-build 0f2925
 * This library is distributed in the hope that it will be useful,
rpm-build 0f2925
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build 0f2925
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build 0f2925
 * Lesser General Public License for more details.
rpm-build 0f2925
 *
rpm-build 0f2925
 * You should have received a copy of the GNU Lesser General Public
rpm-build 0f2925
 * License along with this library; if not, write to the Free Software
rpm-build 0f2925
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
rpm-build 0f2925
 *)
rpm-build 0f2925
rpm-build 0f2925
(** Efficient bit sets.
rpm-build 0f2925
rpm-build 0f2925
 A bitset is an array of boolean values that can be accessed with indexes
rpm-build 0f2925
 like an array but provides a better memory usage (divided by 8) for a
rpm-build 0f2925
 very small speed trade-off. *)
rpm-build 0f2925
rpm-build 0f2925
type t
rpm-build 0f2925
rpm-build 0f2925
exception Negative_index of string
rpm-build 0f2925
(** When a negative bit value is used for one of the BitSet functions,
rpm-build 0f2925
 this exception is raised with the name of the function. *)
rpm-build 0f2925
rpm-build 0f2925
val empty : unit ->  t
rpm-build 0f2925
(** Create an empty bitset of size 0, the bitset will automatically expand
rpm-build 0f2925
 when needed. *)
rpm-build 0f2925
rpm-build 0f2925
val create : int -> t
rpm-build 0f2925
(** Create an empty bitset with an initial size (in number of bits). *)
rpm-build 0f2925
rpm-build 0f2925
val copy : t -> t
rpm-build 0f2925
(** Copy a bitset : further modifications of first one will not affect the
rpm-build 0f2925
 copy. *)
rpm-build 0f2925
rpm-build 0f2925
val clone : t -> t
rpm-build 0f2925
(** Same as [copy] *)
rpm-build 0f2925
rpm-build 0f2925
val set : t -> int -> unit
rpm-build 0f2925
(** [set s n] sets the nth-bit in the bitset [s] to true. *)
rpm-build 0f2925
rpm-build 0f2925
val unset : t -> int -> unit
rpm-build 0f2925
(** [unset s n] sets the nth-bit in the bitset [s] to false. *)
rpm-build 0f2925
rpm-build 0f2925
val put : t -> bool -> int -> unit
rpm-build 0f2925
(** [put s v n] sets the nth-bit in the bitset [s] to [v]. *)
rpm-build 0f2925
rpm-build 0f2925
val toggle : t -> int -> unit
rpm-build 0f2925
(** [toggle s n] changes the nth-bit value in the bitset [s]. *)
rpm-build 0f2925
rpm-build 0f2925
val is_set : t -> int -> bool
rpm-build 0f2925
(** [is_set s n] returns true if nth-bit in the bitset [s] is set,
rpm-build 0f2925
 or false otherwise. *)
rpm-build 0f2925
rpm-build 0f2925
val compare : t -> t -> int
rpm-build 0f2925
(** [compare s1 s2] compares two bitsets. Highest bit indexes are
rpm-build 0f2925
 compared first. *)
rpm-build 0f2925
rpm-build 0f2925
val equals : t -> t -> bool
rpm-build 0f2925
(** [equals s1 s2] returns true if, and only if, all bits values in s1 are
rpm-build 0f2925
  the same as in s2. *)
rpm-build 0f2925
rpm-build 0f2925
val count : t -> int
rpm-build 0f2925
(** [count s] returns the number of bits set in the bitset [s]. *)
rpm-build 0f2925
rpm-build 0f2925
val enum : t -> int Enum.t
rpm-build 0f2925
(** [enum s] returns an enumeration of bits which are set
rpm-build 0f2925
  in the bitset [s]. *)
rpm-build 0f2925
rpm-build 0f2925
val intersect : t -> t -> unit
rpm-build 0f2925
(** [intersect s t] sets [s] to the intersection of the sets [s] and [t]. *)
rpm-build 0f2925
rpm-build 0f2925
val unite : t -> t -> unit
rpm-build 0f2925
(** [unite s t] sets [s] to the union of the sets [s] and [t]. *)
rpm-build 0f2925
rpm-build 0f2925
val differentiate : t -> t -> unit
rpm-build 0f2925
(** [differentiate s t] removes the elements of [t] from [s]. *)
rpm-build 0f2925
rpm-build 0f2925
val differentiate_sym : t -> t -> unit
rpm-build 0f2925
(** [differentiate_sym s t] sets [s] to the symmetrical difference of the
rpm-build 0f2925
  sets [s] and [t]. *)
rpm-build 0f2925
rpm-build 0f2925
val inter : t -> t -> t
rpm-build 0f2925
(** [inter s t] returns the intersection of sets [s] and [t]. *)
rpm-build 0f2925
rpm-build 0f2925
val union : t -> t -> t
rpm-build 0f2925
(** [union s t] return the union of sets [s]  and [t]. *)
rpm-build 0f2925
rpm-build 0f2925
val diff : t -> t -> t
rpm-build 0f2925
(** [diff s t] returns [s]-[t]. *)
rpm-build 0f2925
rpm-build 0f2925
val sym_diff : t -> t -> t
rpm-build 0f2925
(** [sym_diff s t] returns the symmetrical difference of [s] and [t]. *)