Req #48358 [Com]: SplDoublyLinkedList needs an insertAfterIterator() method or something similar

2012-11-29 Thread rdo...@php.net
Edit report at https://bugs.php.net/bug.php?id=48358edit=1

 ID: 48358
 Comment by: rdo...@php.net
 Reported by:dannel at aaronexodus dot com
 Summary:SplDoublyLinkedList needs an insertAfterIterator()
 method or something similar
 Status: Assigned
 Type:   Feature/Change Request
 Package:SPL related
 PHP Version:5.3.0RC2
 Assigned To:colder
 Block user comment: N
 Private report: N

 New Comment:

I'm also running into this, usual implementations of DoublyLinkedList describe 
the 
insertBefore and insertAfter methods, wondering why they were left out in this 
implementation.


Previous Comments:

[2012-11-01 00:57:12] dnwake at gmail dot com

This is ridiculous.  

Efficiency of inserting and deleting in the middle of the list is the main 
motivation for using a linked list in the first place.


[2011-04-15 21:23:51] omercan at gmail dot com

O(n) complexity should be expected from a list data structure along with no 
array access. The drawback of lists is they lack direct access to the elements 
by their position. Well, that's not the case with SplDoublyLinkedList because 
there's array access. So, it's a different implementation as far as it seems.

In my opinion, the problem with SplDoublyLinkedList is that the main operations 
are left to be implemented in the user land, which require iterating over the 
list in each. This class can be much more valuable if the following operations 
are included:

clear() - clear all elements

remove($value) - return number of removals b/c $value can be more than 1

sort(Closure $predicate) - sort without keeping key association

swap($list) - swap with another list or a Traversable instance

unique() - return the unique values in the list, possibly in a new list


[2010-05-22 13:46:01] 1000235409 at smail dot shnu dot edn dot cn

i have encountered the same problem today, after this was modified for 1 year...

but i have a solution to solve this problem. write anohter class with a lots of 
spldoublylinkedlists inside it. however, complex algorithm may be used...


[2009-05-21 17:02:15] dannel at aaronexodus dot com

Description:

The SplDoublyLinkedList is great, but it lacks a way to insert a node somewhere 
in the middle of the list.

One could technically extend the class and provide that functionality, but due 
to the fact that there seem to be [documented] data members in 
SplDoublyLinkedList, the only way to do it would be to find the reference node, 
insert the new node, and move all of the following nodes up one slot in the 
list, resulting in O(n) performance for an insert.

I propose adding an insertAfterIterator() method which would place the new node 
after the current node the iterator points to.

Another option could be an insertAfterArrayKey() method which would act 
similarly, but would find the reference node via a given array key, which might 
be a little more straightforward to use in code.

Each should probably have an insertBefore*() counterpart as well.







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=48358edit=1


Req #53439 [Com]: DatePeriod does not expose any properties

2012-08-30 Thread rdo...@php.net
Edit report at https://bugs.php.net/bug.php?id=53439edit=1

 ID: 53439
 Comment by: rdo...@php.net
 Reported by:from dot php dot net at brainbox dot cz
 Summary:DatePeriod does not expose any properties
 Status: Assigned
 Type:   Feature/Change Request
 Package:Date/time related
 Operating System:   Windows XP SP3
 PHP Version:5.3.3
 Assigned To:derick
 Block user comment: N
 Private report: N

 New Comment:

Same thing happens with DateInterval


Previous Comments:

[2012-05-30 19:15:28] krebs dot seb at googlemail dot com

Anything new here? As far as I understood cataphract a patch exists. What 
happened to it?


[2011-01-09 06:00:13] cataphr...@php.net

Reassigning to Derick, as the patch I've written is under his consideration.


[2010-12-01 17:58:19] from dot php dot net at brainbox dot cz

Description:

The DatePeriod instance does not expose its internal properties, thus makes 
impossible to extend the class.

The properties are not visible in the reflection as well. Also, when I cast the 
instance to array (which usually exposes all properties), no props are shown.

The draft of the test follows.

Test script:
---
$dp = new DatePeriod(new DateTime('2010-01-01'), new DateInterval('P1D'), 2);
$r = new ReflectionObject($dp);
$arr = (array)$dp; // cast to array to see the values of propeties

echo Properties:\r\n;
foreach($r-getProperties() as $v) {
echo $v-getName().\r\n;
}
echo \r\n;

echo Methods:\r\n;
foreach($r-getMethods() as $v) {
echo $v-getName().\r\n;
}
echo \r\n;

echo Array cast:\r\n;
echo strtr(print_r($arr, true), \0, '_');

Expected result:

Properties:
any_valid_properties...
...listed_here_after_implementing

Array cast:
Array
(
   any_valid_properties...
   ...listed_here_after_implementing
)


Actual result:
--
Properties:

Array cast:
Array
(
)







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=53439edit=1