The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SQL::Engine::Collection - Generic Object Container

ABSTRACT

Generic Object Container

SYNOPSIS

  use SQL::Engine::Collection;

  my $collection = SQL::Engine::Collection->new;

  # $collection->count;

  # 0

DESCRIPTION

This package provides a generic container for working with sets of objects.

LIBRARIES

This package uses type constraints from:

Types::Standard

ATTRIBUTES

This package has the following attributes:

items

  items(ArrayRef[Object])

This attribute is read-only, accepts (ArrayRef[Object]) values, and is optional.

METHODS

This package implements the following methods:

clear

  clear() : Bool

The clear method clears the collection and returns an empty list.

clear example #1
  # given: synopsis

  $collection->clear;

count

  count() : Int

The count method counts and returns the number of items in the collection.

count example #1
  # given: synopsis

  $collection->count;

each

  each(CodeRef $value) : ArrayRef[Any]

The each method iterates through the collection executing the callback for each item and returns the set of results.

each example #1
  # given: synopsis

  $collection->each(sub {
    my ($item) = shift;

    $item
  });

first

  first() : Maybe[Object]

The first method returns the first item in the collection.

first example #1
  # given: synopsis

  $collection->first;

last

  last() : Maybe[Object]

The last method returns the last item in the collection.

last example #1
  # given: synopsis

  $collection->last;

list

  list() : ArrayRef

The list method returns the collection as a list of items.

list example #1
  # given: synopsis

  $collection->list;

pop

  pop() : Maybe[Object]

The pop method removes and returns an item from the tail of the collection.

pop example #1
  # given: synopsis

  $collection->pop;

pull

  pull() : Maybe[Object]

The pull method removes and returns an item from the head of the collection.

pull example #1
  # given: synopsis

  $collection->pull;

push

  push(Object @values) : Int

The push method inserts an item onto the tail of the collection and returns the count.

push example #1
  # given: synopsis

  $collection->push(bless {});

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues