wp_find_hierarchy_loop_tortoise_hare [ WordPress Function ]
wp_find_hierarchy_loop_tortoise_hare ( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false )
| Access: |
|
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Benzer Fonksiyonlar: wp_find_hierarchy_loop, wp_check_term_hierarchy_for_loops, wp_check_post_hierarchy_for_loops, _wp_ajax_add_hierarchical_term
Uses the "The Tortoise and the Hare" algorithm to detect loops.
For every step of the algorithm, the hare takes two steps and the tortoise one. If the hare ever laps the tortoise, there must be a loop.
Source
<?php
function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) {
$tortoise = $hare = $evanescent_hare = $start;
$return = array();
// Set evanescent_hare to one past hare
// Increment hare two steps
while (
$tortoise
&&
( $evanescent_hare = isset( $override[$hare] ) ? $override[$hare] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) )
&&
( $hare = isset( $override[$evanescent_hare] ) ? $override[$evanescent_hare] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) )
) {
if ( $_return_loop )
$return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true;
// tortoise got lapped - must be a loop
if ( $tortoise == $evanescent_hare || $tortoise == $hare )
return $_return_loop ? $return : $tortoise;
// Increment tortoise by one step
$tortoise = isset( $override[$tortoise] ) ? $override[$tortoise] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) );
}
return false;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- wp_find_hierarchy_loop_tortoise_hare (WordPress Function ...
WordPress lookup for wp_find_hierarchy_loop_tortoise_hare, a WordPress Function. wpseek.com is a WordPress-centric search tool for developers and theme ...
wpseek.com - Ticket #14662 - WordPress Trac
arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $map, $start ) ) return array(); return wp_find_hierarchy_loop_tortoise_hare( $map, ...
core.trac.wordpress.org - #19552 (Split functions.php) – WordPress Trac
... __return_zero() __return_empty_array() send_nosniff_header() _wp_mysql_week() wp_find_hierarchy_loop() wp_find_hierarchy_loop_tortoise_hare() ...
core.trac.wordpress.org - SpinforAmerica.com
arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback ... wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, ...
www.spinforamerica.com