data_structures
[
class tree: data_structures
] [
index: data_structures
] [
all elements
]
changelog
install
readme
Todo List
Packages:
core
communication
databases
data_structures
filesystem
forms
GilliGan
html
Services_JSON
Source for file Vector.class.php
Documentation is available at
Vector.class.php
<?php
/**
* For including this file you have to define the constant "CLASSPATH".
* Because every include in the framework depends on the CLASSPATH definition.
* The CLASSPATH means the relative path to the folder that contains the
* framework GilliGan.
*
*
@package
data_structures
*/
if
(
!
defined
(
"CLASSPATH"
) )
{
echo
"<h3>You have to define the constant CLASSPATH!</h3>\r\n"
;
echo
"Example: define( 'CLASSPATH', '../path/to/classes/' );\r\n"
;
exit
(
)
;
}
/**
*
*/
require_once
(
CLASSPATH
.
"core/Arrays.class.php"
)
;
/**
*
@package
data_structures
*
*
@version
0.1.53
*
@author
Daniel Plücken <daniel@debakel.net>
*
@license
http://www.gnu.org/copyleft/lesser.html
* GNU Lesser General Public License
*
@copyright
Copyright (C) 2004 Daniel Plücken <daniel@debakel.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*/
class
Vector
extends
Arrays
{
/**
*
@var
array
$mixed
*
@access
private
*/
var
$mixed
;
/**
* Constructor
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
array
$array*
The array to manage.
*
@return
void
*/
function
Vector
(
$arr
=
array
(
) )
{
if
(
is_array
(
$arr
) )
$this
->
mixed
=
$arr
;
else
die
(
"Vector: The given value has to be an array."
)
;
}
/**
* Push one element onto the end of the intern array.
*
*
@version
1.0
*
@since
0.1.53
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
void
*/
function
add
(
&
$item
)
{
$this
->
mixed
[
]
=
&
$item
;
}
/**
* Sets the pointer to the value zero.
*
*
@version
1.0
*
@since
0.1.2
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
void
*/
function
resetPointer
(
)
{
reset
(
$this
->
mixed
)
;
}
/**
* Sets the pointer to the given value.
*
*
@version
1.0
*
@since
0.1.4
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
integer
$int
*
@return
boolean
*/
function
select
(
$int
)
{
if
(
count
(
$this
->
mixed
)
<=
0
)
return
false
;
$int
=
$int
%
count
(
$this
->
mixed
)
;
reset
(
$this
->
mixed
)
;
for
(
$i
=
0
;
$i
<
$int
;
$i
++
)
next
(
$this
->
mixed
)
;
return
true
;
}
/**
* Returns the previous entry of this one who is associated with the pointer
* and arises the pointer by one.
*
*
@version
1.0
*
@since
0.1.2
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
integer
$int
Index of record to remove.
*/
function
next
(
)
{
return
next
(
$this
->
mixed
)
;
}
/**
* Returns the previous entry of this one who is associated with the pointer
* and abates the pointer by one.
*
*
@version
1.0
*
@since
0.1.2
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
mixed
*/
function
previous
(
)
{
return
prev
(
$this
->
mixed
)
;
}
/**
* Returns the previous entry of this one who is associated with the pointer
* and abates the pointer by one.
* This method is an alias of the method previous.
*
*
@version
1.0
*
@since
0.1.2
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
mixed
*/
function
prev
(
)
{
return
prev
(
$this
->
mixed
)
;
}
/**
* Removes the record at $int-index. All entrys behind the deleted record
* moving up by one position.
*
*
@version
1.0
*
@since
0.1.1
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
integer
$int
Index of record to remove.
*
@return
void
*/
function
deleteRecordAt
(
&
$int
)
{
array_splice
(
$this
->
mixed
,
$int
,
1
)
;
}
/**
* Searches the first record of $value. If it is found it will be delete. All
* entrys behind the deleted record moving up by one position.
*
*
@version
1.1
*
@since
0.1.1
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
mixed
$value
The value that should be searched.
*
@return
void
*/
function
deleteRecordValue
(
&
$value
)
{
$this
->
mixed
=
parent
::
deleteRecordValue
(
$value
,
$this
->
mixed
)
;
}
/**
* Returns the value of the current pointer position.
*
*
@version
1.0
*
@since
0.1.5
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
mixed
*/
function
getCurrent
(
)
{
return
current
(
$this
->
mixed
)
;
}
/**
* Returns the position of the first record that matches the value
* of $mixedVal.
*
*
@version
1.1
*
@since
0.1.1
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
mixed
$mixedVal
The value that should be searched.
*
@return
integer
|
false
*/
function
getFirstIndexOf
(
&
$mixedVal
)
{
return
parent
::
getFirstIndexOf
(
$mixedVal
,
$this
->
mixed
)
;
}
/**
* Returns a random record of this vector.
*
*
@version
1.0
*
@since
0.1.1
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
array
*/
function
getRandomRecord
(
)
{
return
parent
::
getRandomRecord
(
$this
->
mixed
)
;
}
/**
* Returns true if $this->mixed (the internal array that is managed by the
* class Vector) contains $record else it will return false.
*
*
@version
1.1
*
@since
0.1.1
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
mixed
$record
The value which should be compared with
* the records of the array.
*
@return
boolean
*/
function
contains
(
&
$record
)
{
return
parent
::
contains
(
$record
)
;
}
/**
* Fills $record in $this->mixed only if $this->mixed does not already
* contains it.
*
*
@version
1.0
*
@since
0.1.1
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
mixed
$record
The value which should be filled in the array.
*
@return
void
*/
function
uniqueInsert
(
&
$record
)
{
parent
::
uniqueInsert
(
$this
->
mixed
,
$record
)
;
}
/**
* Removes doubly occuring records in $this->mixed.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
void
*/
function
uniqueRecords
(
)
{
$this
->
mixed
=
parent
::
uniqueRecords
(
$this
->
mixed
)
;
}
}
// End of class Vector
?>
Documentation generated on Thu, 05 Jun 2008 19:15:37 +0200 by
phpDocumentor 1.4.1