Your hash function is, um, unusual. Your for loop does nothing. Assuming that is what you really wanted, this is what you function is actually doing:
which is consierably faster - not iterating i over the length of a string.
I have a file with a format of
A,2
B,2
G,3
A,2
A,3
A,2
D,7
A,2
E,2
A,2
I need to create a sum of each alphabet with the numbers assigned to it using awk. (2 Replies)
I have a script with dynamic hash of hashes , and I want to print the entire hash (with all other hashes).
Itried to do it recursively by checking if the current key is a hash and if yes call the current function again with refference to the sub hash.
Most of the printing seems to be OK but in... (1 Reply)
I analysed disk performance with blktrace and get some data:
read:
8,3 4 2141 2.882115217 3342 Q R 195732187 + 32
8,3 4 2142 2.882116411 3342 G R 195732187 + 32
8,3 4 2144 2.882117647 3342 I R 195732187 + 32
8,3 4 2145 ... (1 Reply)
Hello,
I have a hash in hsh. I need to assign it to another hash globalHsh. I think the below statement does not work
$globalHsh{$id} = %hsh;
What is the right way to assign it?
Thanks (3 Replies)
Can Someone explain me why even using Tie::IxHash I can not get the output data in the same order that it was inserted? See code below.
#!/usr/bin/perl
use warnings;
use Tie::IxHash;
use strict;
tie (my %programs, "Tie::IxHash");
while (my $line = <DATA>) {
chomp $line;
my(... (1 Reply)
Hi,
In Perl, is it possible to use a range of numbers with '..' as a key in a hash?
Something in like:
%hash = (
'768..1536' => '1G',
'1537..2560' => '2G'
);
That is, the range operation is evaluated, and all members of the range are... (3 Replies)
Hi,
I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all .
my %result (
$abc => {
'data_count' => '10',
'ID' => 'ABC122',
}
$def => {
'data_count' => '20',
'ID' => 'defASe',
... (1 Reply)
Hi, I have a hash of hash where it has
name, activities and count
i have data like this -
$result->{$name}->{$activities} = $value;
content of that are -
name - robert tom cat peter
activities - running, eating, sleeping , drinking, work
i need to print output as below
... (3 Replies)
Discussion started by: asak
3 Replies
LEARN ABOUT PHP
quickhashintstringhash
QUICKHASHINTSTRINGHASH(3) 1 QUICKHASHINTSTRINGHASH(3)The QuickHashIntStringHash classINTRODUCTION
This class wraps around a hash containing integer numbers, where the values are strings. Hashes are also available as implementation of
the ArrayAccess interface.
Hashes can also be iterated over with foreach as the Iterator interface is implemented as well. The order of which elements are returned
in is not guaranteed.
CLASS SYNOPSIS
QuickHashIntStringHash
QuickHashIntStringHash
Constants
o const integer$QuickHashIntStringHash::CHECK_FOR_DUPES1
o const integer$QuickHashIntStringHash::DO_NOT_USE_ZEND_ALLOC2
o const integer$QuickHashIntStringHash::HASHER_NO_HASH256
o const integer$QuickHashIntStringHash::HASHER_JENKINS1512
o const integer$QuickHashIntStringHash::HASHER_JENKINS21024
Methods
o public bool QuickHashIntStringHash::add (int $key, string $value)
o public QuickHashIntStringHash::__construct (int $size, [int $options])
o public bool QuickHashIntStringHash::delete (int $key)
o public bool QuickHashIntStringHash::exists (int $key)
o public mixed QuickHashIntStringHash::get (int $key)
o public int QuickHashIntStringHash::getSize (void )
o publicstatic QuickHashIntStringHash QuickHashIntStringHash::loadFromFile (string $filename, [int $size], [int $options])
o publicstatic QuickHashIntStringHash QuickHashIntStringHash::loadFromString (string $contents, [int $size], [int $options])
o public void QuickHashIntStringHash::saveToFile (string $filename)
o public string QuickHashIntStringHash::saveToString (void )
o public int QuickHashIntStringHash::set (int $key, string $value)
o public bool QuickHashIntStringHash::update (int $key, string $value)
PREDEFINED CONSTANTS
o QuickHashIntStringHash::CHECK_FOR_DUPES -If enabled, adding duplicate elements to a set (through either add() or loadFromFile())
will result in those elements to be dropped from the set. This will take up extra time, so only used when it is required.
o QuickHashIntStringHash::DO_NOT_USE_ZEND_ALLOC -Disables the use of PHP's internal memory manager for internal set structures. With
this option enabled, internal allocations will not count towards the memory_limit settings.
o QuickHashIntStringHash::HASHER_NO_HASH -Selects to not use a hashing function, but merely use a modulo to find the bucket list
index. This is not faster than normal hashing, and gives more collisions.
o QuickHashIntStringHash::HASHER_JENKINS1 -This is the default hashing function to turn the integer hashes into bucket list indexes.
o QuickHashIntStringHash::HASHER_JENKINS2 -Selects a variant hashing algorithm.
PHP Documentation Group QUICKHASHINTSTRINGHASH(3)