GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Venus::Role::Mappable(3) User Contributed Perl Documentation Venus::Role::Mappable(3)

Venus::Role::Mappable - Mappable Role

Mappable Role for Perl 5

  package Example;
  use Venus::Class;
  with 'Venus::Role::Mappable';
  sub all;
  sub any;
  sub call;
  sub count;
  sub delete;
  sub each;
  sub empty;
  sub exists;
  sub grep;
  sub iterator;
  sub keys;
  sub map;
  sub none;
  sub one;
  sub pairs;
  sub random;
  sub reverse;
  sub slice;
  package main;
  my $example = Example->new;
  # $example->random;

This package provides a specification for the consuming package to implement methods that makes the object mappable. See Venus::Array and Venus::Hash as other examples of mappable classes.

This package provides the following methods:

  all(coderef $code) (boolean)

The all method should return true if the callback returns true for all of the elements provided.

Since 0.01

all example 1
  # given: synopsis;
  my $all = $example->all(sub {
    # ...
  });
    

  any(coderef $code) (boolean)

The any method should return true if the callback returns true for any of the elements provided.

Since 0.01

any example 1
  # given: synopsis;
  my $any = $example->any(sub {
    # ...
  });
    

  count() (number)

The count method should return the number of top-level element in the data structure.

Since 0.01

count example 1
  # given: synopsis;
  my $count = $example->count;
    

  delete(string $key) (any)

The delete method returns should remove the item in the data structure based on the key provided, returning the item.

Since 0.01

delete example 1
  # given: synopsis;
  my $delete = $example->delete(...);
    

  each(coderef $code) (arrayref)

The each method should execute the callback for each item in the data structure passing the key and value as arguments.

Since 0.01

each example 1
  # given: synopsis;
  my $results = $example->each(sub {
    # ...
  });
    

  empty() (Value)

The empty method should drop all items from the data structure.

Since 0.01

empty example 1
  # given: synopsis;
  my $empty = $example->empty;
    

  exists(string $key) (boolean)

The exists method should return true if the item at the key specified exists, otherwise it returns false.

Since 0.01

exists example 1
  # given: synopsis;
  my $exists = $example->exists(...);
    

  grep(coderef $code) (arrayref)

The grep method should execute a callback for each item in the array, passing the value as an argument, returning a value containing the items for which the returned true.

Since 0.01

grep example 1
  # given: synopsis;
  my $results = $example->grep(sub {
    # ...
  });
    

  iterator() (coderef)

The iterator method should return a code reference which can be used to iterate over the data structure. Each time the iterator is executed it will return the next item in the data structure until all items have been seen, at which point the iterator will return an undefined value.

Since 0.01

iterator example 1
  # given: synopsis;
  my $iterator = $example->iterator;
    

  keys() (arrayref)

The keys method should return an array reference consisting of the keys of the data structure.

Since 0.01

keys example 1
  # given: synopsis;
  my $keys = $example->keys;
    

  map(coderef $code) (arrayref)

The map method should iterate over each item in the data structure, executing the code reference supplied in the argument, passing the routine the value at the current position in the loop and returning an array reference containing the items for which the argument returns a value or non-empty list.

Since 0.01

map example 1
  # given: synopsis;
  my $results = $example->map(sub {
    # ...
  });
    

  none(coderef $code) (boolean)

The none method should return true if none of the items in the data structure meet the criteria set by the operand and rvalue.

Since 0.01

none example 1
  # given: synopsis;
  my $none = $example->none(sub {
    # ...
  });
    

  one(coderef $code) (boolean)

The one method should return true if only one of the items in the data structure meet the criteria set by the operand and rvalue.

Since 0.01

one example 1
  # given: synopsis;
  my $one = $example->one(sub {
    # ...
  });
    

  pairs(coderef $code) (tuple[arrayref, arrayref])

The pairs method should return an array reference of tuples where each tuple is an array reference having two items corresponding to the key and value for each item in the data structure.

Since 0.01

pairs example 1
  # given: synopsis;
  my $pairs = $example->pairs(sub {
    # ...
  });
    

  random() (any)

The random method should return a random item from the data structure.

Since 0.01

random example 1
  # given: synopsis;
  my $random = $example->random;
    

  reverse() (arrayref)

The reverse method should returns an array reference containing the items in the data structure in reverse order if the items in the data structure are ordered.

Since 0.01

reverse example 1
  # given: synopsis;
  my $reverse = $example->reverse;
    

  slice(string @keys) (arrayref)

The slice method should return a new data structure containing the elements in the invocant at the key(s) specified in the arguments.

Since 0.01

slice example 1
  # given: synopsis;
  my $slice = $example->slice(...);
    

Awncorp, "awncorp@cpan.org"

Copyright (C) 2022, Awncorp, "awncorp@cpan.org".

This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.

2023-11-27 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.