PHP Classes

File: example.or.BitArray.php

Recommend this page to a friend!
  Classes of Cornelius Bolten   Bit Array   example.or.BitArray.php   Download  
File: example.or.BitArray.php
Role: Example script
Content type: text/plain
Description: or-example script
Class: Bit Array
Manipulate compact arrays of bit values
Author: By
Last change: wrong package-name fixed
Date: 20 years ago
Size: 1,467 bytes
 

Contents

Class file image Download
<?php

   
/**
    * $RCSfile: example.or.BitArray.php,v $
    * @author $Author: Cornelius Bolten $
    * @version $Revision: 1.2 $
    * @package BitArray
    *
    * @copyright
    * The Initial Developer of the Original Code is Cornelius Bolten.
    * Portions created by Cornelius Bolten are Copyright (C) 2004 by Cornelius Bolten.
    * All Rights Reserved.
    * Usage is free for non-commercial work. see http://www.phpclasses.org/browse/package/1540.html
    * for more information.
    *
    * @see
    * Latest releases are available at http://www.phpclasses.org/browse/package/1540.html
    * For feedback, bug reports or enhancements please contact the author at
    * c.bolten@grafiknews.de. Thanks a lot!
    *
    * @description
    * This is a working example for or-comparison of two BitArrays
    *
    **/
   
   
header("Content-Type: text/plain");
    include_once(
"lib.BitArray.php");
   
    function
PrintValues($myList, $myWidth) {
        for(
$i=0;$i<=($myWidth-1); $i++) {
            if(
$myList[$i])
                echo
"true";
            else
                echo
"false";
            echo
"\t";
        }
        echo
"\n";
    }
   
   
$myBA1 = new BitArray(4);
   
$myBA2 = new BitArray(4);
   
   
$myBA1->set(0,false);
   
$myBA1->set(1,false);
   
$myBA1->set(2,true);
   
$myBA1->set(3,true);
   
   
$myBA2->set(0,false);
   
$myBA2->set(1,true);
   
$myBA2->set(2,false);
   
$myBA2->set(3,true);
   
    echo
"\nBA1 values:\n";
   
PrintValues($myBA1->getAll(),4);
    echo
"\nBA2 values:\n";
   
PrintValues($myBA2->getAll(),4);
   
    echo
"\nOR values:\n";
   
$result = $myBA1->_or($myBA2);
   
PrintValues($result,4);


?>