SlideShare a Scribd company logo
1 of 57
Any Which Array
   But Loose
   Michael Labriola
      Digital Primates
Who are you?

Michael Labriola
Senior Consultant at Digital Primates

     Flex Geek
     Component Developer
     Flex Team Mentor
Who were you?

Michael Labriola
Software Engineer

     Embedded Systems Developer
     Reverse Engineer
What is this session about?

This session is part of my continuing quest to
  teach Flash and Flex from the inside out.

Learn what the Flash Player and the Flex
  framework are really doing and you are more
  likely to use them successfully, respect their
  boundaries and extend them in useful ways
One more reason
Let’s call it “Game Theory”.

If you know how something works really well, you
   know which rules you can bend and just how far
   you can bend them before they break.

Sometimes you can even find really creative ways
  out of difficult situations
Standard Disclaimer

I am going to lie to you a lot… a whole lot

Even at this ridiculous level of detail, there is
  much more

All of this is conditional. So, we are just going to
  take one route and go with it
What is an Array?

Arrangement of objects in memory.

Generally used to hold values in a directly index-
  able form
An Array

Mostly contiguous block
 of memory

Holds values

Can grow or shrink in
  size at runtime
An Array Can Be
Homogeneous   Heterogeneous
An Array Can Be
Dense       Sparse
Null versus Sparse
Array with Null   Sparse
What is a Vector?

A Vector is a new type of Array introduced with
  Flash Player 10.

It’s primary benefits are performance and type
   safety
A Vector

Is Dense (no gaps)

Is Homogenous (always
   the same base class)

Can be fixed length
Syntax
Array                        Vector

var a:Array = new Array();   var v:Vector.<uint> =
                                    new Vector.<uint>(n);

a[0] = “value”;              v[0] = “value”; //error
a[1] = 345;                  v[1] = 345;
a.push( 123 );               v.push( 123 );

trace( v.length );           trace( v.length );
A ByteArray
About the lowest level
  memory access there is
  in ActionScript

Let’s you access the raw
  bytes and order of
  data.

Up to you to manage
  what exists inside of
  the array
Syntax
ByteArray

var byteArray:ByteArray = new ByteArray();

byteArray.writeBoolean(true);
byteArray.writeDouble(Math.PI);

byteArray.position = 0;

trace( byteArray.readBoolean() ); //true
trace( byteArray.readDouble() ); //3.1415926535897

trace( byteArray[ 2 ] ); //9… why?
Breaking Apart Pete
      When working with a
      ByteArray, the indices
      do not necessarily
      indicate discrete
      objects. They indicate
      discrete bytes
Position
Byte Array also has a
position indicator. This
indicates the next
place you will read
from or write to.

This is the beginning of
a very important
concept.
Great Things about Array
Array’s can be extremely fast to access data at a
  known index.

They also provide random access, meaning you
  can ask for the value at position 3 without
  caring that there is a position 2
Bad Things about Array
Array’s can be pretty slow when you need to
  insert or delete information from the middle

Moving from element to element (moving from 2
 to 3) takes a fixed amount of time, which is
 good, but you also don’t get a speed advantage
 because those two are right next to eachother
Array Before Insert
Array Move Elements
Array Insert Element
Array Before Delete
Array Remove Element
Array Collapse
Array Searching
       Searching an Array
         generally involves
         iterating through each
         element looking for the
         value you would like.

       If the array is sorted, you
           can make the search a
           smarter
Array Collections
At some point you may have been told to use the
  ArrayCollection class.

So, what is it? ..It’s a wrapper around an array.

It provides the basic access to array by acting as a
   proxy. This allows ArrayCollection to lie to you
Key Lies
Since ArrayCollection controls all information flow in
  and out of its little regime, it can lie both about
  how big the array is and about the order of the
  elements.

It does this by creating a duplicate array that points
   to the original, when and if it is convenient.

Fortunately, you control this by means of the sort
and filterFunction
Sorted Array Collection
One you have provided
  the ArrayCollection a
  Sort instance and
  called its refresh()
  method, it builds an
  array which maps the
  original elements to
  the new sort
Syntax
ArrayCollection Sort

var ac:ArrayCollection = new ArrayCollection(data);

var ac:ArrayCollection = new ArrayCollection();
var sort:Sort = new Sort();
var field:SortField = new SortField( quot;hireDatequot; );
sort.fields = [ field ];
ac.sort = sort;
ac.refresh();
Collection Resorted
Sorting doesn’t actually need to shift the original data,
just the new internal array.
Searching a Collection
Once an ArrayCollection has been sorted,
  searching it is a very efficient and easy process.

The reduction in time to sort a large
  ArrayCollection is very significant over an array.
Filtered Array Collection
One you have provided
  the ArrayCollection
  with a filter function
  and called its refresh()
  method, it builds an
  array which maps the
  original elements to
  the new array if they
  pass the test in your
  function
Syntax
ArrayCollection Filter

var ac:ArrayCollection = new ArrayCollection();
ac.filterFunction = ifIFeelLikeIt;
ac.refresh();

function ifIFeelLikeIt( item:Object ):Boolean {
   //do some logic and decide
   return ( item != Andy );
}
Andy Filtered Out
Another Key Feature
While not busy deceiving you, ArrayCollection has
 a handful of really useful additional features.

The reason most people use ArrayCollection, even
  if they aren’t sure why, is that it is an event
  dispatcher.

When you use the ArrayCollection with
 DataBinding, the ArrayCollection informs you of
 changes
Collection Broadcaster
Collection Internals
trace( collection[ 3 ] );    getProperty( 3 );

                              getItemAt( 3 );

                            get localIndex[ 3 ];



                            setProperty( 3, 8 );   collection[ 3 ] = 8;

                             setItemAt( 8, 3 );

                              list.setItemAt;

                              Update Value

                              Dispatch Event
Final One
Through inheritance ArrayCollection also provides
  one final important feature, it can work with a
  cursor.

A bit like the position in a ByteArray, the cursor
  points to a given object in the collection. You
  can use the cursor to move forward to the next
  item, move back to a previous item, seek to
  well-known locations or search sorted data.
Cursor
Cursor.moveNext()
DataGrid and List Base
In fact, the List base controls in Flex use these
  cursors pretty much exclusively inside of these
  components.

One of the reasons they can accept many
  different types of input is they simply wrap the
  input in one of (n) classes that implement
  ICollectionView
ICollectionView
ICollectionView mandates that an object can
  dispatch events, understands how to sort, filter
  and refresh along with a handful of other items,
  and, most importantly, that the object can
  create a cursor that will move through an child
  objects.
ICollectionView
This is really important as it allows us to use
  various types of Data Structures, other than
  just ArrayCollection to fill this need.

For example, we can trivially make a
  VectorCollection which uses vectors instead of
  Arrays. We can create a ByteArrayCollection
  should we feel so inclined.
Cursor/Iterator
With this new found knowledge, we could also
 explore data structures that don’t exist in Flex
 today, but could.

One data structure in particular is really fantastic
  when you need to do frequent inserts/deletes
  or simply move through the values sequentially,
  a linked list.
Linked List
A linked list is a data structure that is just a
  sequence of pieces of data, often called nodes.

Linked lists can be implemented in a single
  fashion, where each node only knows about the
  next, or, in a double fashion where each node
  knows who came before it and who came after
  it
Linked List
Each node in this linked
  list knows about who
  is sequentially before
  it, and who is
  sequentially after.

They don’t have any
  information about
  the other nodes
Inserting List
This makes the process
  of inserting into a list
  extremely efficient.

There is no need to
  move any of the
  existing nodes, you
  simply change who
  (in this case) Pete
  and Andy believe are
  next and previous.
Deleting List
Deleting is equally as
  efficient.

In this case when we
  chose to remove
  Andy, we simply
  change the previous
  and next of Pete and
  Thomas
Andy is GCed
Eventually in the
  future, the garbage
  collector ruthlessly
  slaughters Andy.

However, that is not
  the concern of this
  session.
Searching List
       Searching an unsorted list
         takes about the same
         effort as searching an
         Array.
Searching By Index
         Where linked lists are
          much slower is when
          you need to find an
          item at a particular
          index. For an array, that
          is a very fast operation.

         Here it requires a walk
           through the list.
Working with Cursors
          The paradigm used by
            cursors, however,
            works very well with
            lists where we
            generally are moving
            between nodes
Results
For good measure, let’s take a look at some data
Q&A
Seriously? You must have some questions by now?
Resources
Blog Aggregator (All of the Digital Primates)
http://blogs.digitalprimates.net/

My Blog Specifically
http://blogs.digitalprimates.net/codeSlinger/

Follow Me on Twitter
mlabriola

More Related Content

What's hot

What's hot (20)

Java Collections
Java  Collections Java  Collections
Java Collections
 
Java - Collections framework
Java - Collections frameworkJava - Collections framework
Java - Collections framework
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structures
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
 
Collections and generic class
Collections and generic classCollections and generic class
Collections and generic class
 
Generics
GenericsGenerics
Generics
 
Collections framework
Collections frameworkCollections framework
Collections framework
 
Collections - Array List
Collections - Array List Collections - Array List
Collections - Array List
 
STRINGS IN JAVA
STRINGS IN JAVASTRINGS IN JAVA
STRINGS IN JAVA
 
Java collection
Java collectionJava collection
Java collection
 
Collections
CollectionsCollections
Collections
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
Lecture 7- Iterator and for loop over arrays
Lecture 7- Iterator and for loop over arraysLecture 7- Iterator and for loop over arrays
Lecture 7- Iterator and for loop over arrays
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
 
Lecture07 the linked-list_as_a_data_structure_v3
Lecture07 the linked-list_as_a_data_structure_v3Lecture07 the linked-list_as_a_data_structure_v3
Lecture07 the linked-list_as_a_data_structure_v3
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets
 
Collection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanCollection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshan
 
L11 array list
L11 array listL11 array list
L11 array list
 
Java ArrayList Video Tutorial
Java ArrayList Video TutorialJava ArrayList Video Tutorial
Java ArrayList Video Tutorial
 
Java Collection framework
Java Collection frameworkJava Collection framework
Java Collection framework
 

Similar to Any Which Array But Loose Michael Labriola Digital Primates

ppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptxppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptxAmanRai352102
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaEdureka!
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2Abbott
 
Data structure lecture 2 (pdf)
Data structure lecture 2 (pdf)Data structure lecture 2 (pdf)
Data structure lecture 2 (pdf)Abbott
 
Java Unit 2 (Part 2)
Java Unit 2 (Part 2)Java Unit 2 (Part 2)
Java Unit 2 (Part 2)SURBHI SAROHA
 
Dynamic memory allocation and linked lists
Dynamic memory allocation and linked listsDynamic memory allocation and linked lists
Dynamic memory allocation and linked listsDeepam Aggarwal
 
Collections and its types in C# (with examples)
Collections and its types in C# (with examples)Collections and its types in C# (with examples)
Collections and its types in C# (with examples)Aijaz Ali Abro
 
Collections Java e Google Collections
Collections Java e Google CollectionsCollections Java e Google Collections
Collections Java e Google CollectionsAndré Faria Gomes
 
12_-_Collections_Framework
12_-_Collections_Framework12_-_Collections_Framework
12_-_Collections_FrameworkKrishna Sujeer
 
Describes the concept of ADTS and illustrates the concept with three o.docx
Describes the concept of ADTS and illustrates the concept with three o.docxDescribes the concept of ADTS and illustrates the concept with three o.docx
Describes the concept of ADTS and illustrates the concept with three o.docxearleanp
 
Collections - Lists & sets
Collections - Lists & setsCollections - Lists & sets
Collections - Lists & setsRatnaJava
 
4.1 sequentioal search
4.1 sequentioal search4.1 sequentioal search
4.1 sequentioal searchKrish_ver2
 
3.2 stacks and arrays
3.2   stacks and arrays3.2   stacks and arrays
3.2 stacks and arraysallenbailey
 

Similar to Any Which Array But Loose Michael Labriola Digital Primates (20)

ppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptxppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptx
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
 
Data structure lecture 2 (pdf)
Data structure lecture 2 (pdf)Data structure lecture 2 (pdf)
Data structure lecture 2 (pdf)
 
TSAT Presentation1.pptx
TSAT Presentation1.pptxTSAT Presentation1.pptx
TSAT Presentation1.pptx
 
Data structures
Data structuresData structures
Data structures
 
Java Unit 2 (Part 2)
Java Unit 2 (Part 2)Java Unit 2 (Part 2)
Java Unit 2 (Part 2)
 
Dynamic memory allocation and linked lists
Dynamic memory allocation and linked listsDynamic memory allocation and linked lists
Dynamic memory allocation and linked lists
 
LectureNotes-06-DSA
LectureNotes-06-DSALectureNotes-06-DSA
LectureNotes-06-DSA
 
Collections and its types in C# (with examples)
Collections and its types in C# (with examples)Collections and its types in C# (with examples)
Collections and its types in C# (with examples)
 
Java collections
Java collectionsJava collections
Java collections
 
Collections Java e Google Collections
Collections Java e Google CollectionsCollections Java e Google Collections
Collections Java e Google Collections
 
12_-_Collections_Framework
12_-_Collections_Framework12_-_Collections_Framework
12_-_Collections_Framework
 
Describes the concept of ADTS and illustrates the concept with three o.docx
Describes the concept of ADTS and illustrates the concept with three o.docxDescribes the concept of ADTS and illustrates the concept with three o.docx
Describes the concept of ADTS and illustrates the concept with three o.docx
 
Collections - Lists & sets
Collections - Lists & setsCollections - Lists & sets
Collections - Lists & sets
 
Collections Training
Collections TrainingCollections Training
Collections Training
 
Lesson 2.2 abstraction
Lesson 2.2   abstractionLesson 2.2   abstraction
Lesson 2.2 abstraction
 
4.1 sequentioal search
4.1 sequentioal search4.1 sequentioal search
4.1 sequentioal search
 
3.2 stacks and arrays
3.2   stacks and arrays3.2   stacks and arrays
3.2 stacks and arrays
 

More from michael.labriola

Optimizing Browser Rendering
Optimizing Browser RenderingOptimizing Browser Rendering
Optimizing Browser Renderingmichael.labriola
 
Randori design goals and justification
Randori design goals and justificationRandori design goals and justification
Randori design goals and justificationmichael.labriola
 
Flex 4 components from the firehose
Flex 4 components from the firehoseFlex 4 components from the firehose
Flex 4 components from the firehosemichael.labriola
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audiencemichael.labriola
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audiencemichael.labriola
 
FlexUnit 4 for contributors
FlexUnit 4 for contributorsFlexUnit 4 for contributors
FlexUnit 4 for contributorsmichael.labriola
 
Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy michael.labriola
 
Flex 4 Component Development
Flex 4 Component DevelopmentFlex 4 Component Development
Flex 4 Component Developmentmichael.labriola
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flexmichael.labriola
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Watersmichael.labriola
 
How To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex InfrastructureHow To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex Infrastructuremichael.labriola
 
2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Componentsmichael.labriola
 

More from michael.labriola (20)

Optimizing Browser Rendering
Optimizing Browser RenderingOptimizing Browser Rendering
Optimizing Browser Rendering
 
Randori design goals and justification
Randori design goals and justificationRandori design goals and justification
Randori design goals and justification
 
L2624 labriola
L2624 labriolaL2624 labriola
L2624 labriola
 
Talking trash
Talking trashTalking trash
Talking trash
 
Flex 4 components from the firehose
Flex 4 components from the firehoseFlex 4 components from the firehose
Flex 4 components from the firehose
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audience
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audience
 
FlexUnit 4 for contributors
FlexUnit 4 for contributorsFlexUnit 4 for contributors
FlexUnit 4 for contributors
 
Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy
 
Why test with flex unit
Why test with flex unitWhy test with flex unit
Why test with flex unit
 
Apocalypse Soon
Apocalypse SoonApocalypse Soon
Apocalypse Soon
 
Flex 4 Component Development
Flex 4 Component DevelopmentFlex 4 Component Development
Flex 4 Component Development
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Air Drag And Drop
Air Drag And DropAir Drag And Drop
Air Drag And Drop
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Waters
 
How To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex InfrastructureHow To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex Infrastructure
 
Blaze Ds Slides
Blaze Ds SlidesBlaze Ds Slides
Blaze Ds Slides
 
2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components
 
Dense And Hot 360 Flex
Dense And Hot 360 FlexDense And Hot 360 Flex
Dense And Hot 360 Flex
 
Dense And Hot Web Du
Dense And Hot  Web DuDense And Hot  Web Du
Dense And Hot Web Du
 

Recently uploaded

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Recently uploaded (20)

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Any Which Array But Loose Michael Labriola Digital Primates

  • 1. Any Which Array But Loose Michael Labriola Digital Primates
  • 2. Who are you? Michael Labriola Senior Consultant at Digital Primates Flex Geek Component Developer Flex Team Mentor
  • 3. Who were you? Michael Labriola Software Engineer Embedded Systems Developer Reverse Engineer
  • 4. What is this session about? This session is part of my continuing quest to teach Flash and Flex from the inside out. Learn what the Flash Player and the Flex framework are really doing and you are more likely to use them successfully, respect their boundaries and extend them in useful ways
  • 5. One more reason Let’s call it “Game Theory”. If you know how something works really well, you know which rules you can bend and just how far you can bend them before they break. Sometimes you can even find really creative ways out of difficult situations
  • 6. Standard Disclaimer I am going to lie to you a lot… a whole lot Even at this ridiculous level of detail, there is much more All of this is conditional. So, we are just going to take one route and go with it
  • 7. What is an Array? Arrangement of objects in memory. Generally used to hold values in a directly index- able form
  • 8. An Array Mostly contiguous block of memory Holds values Can grow or shrink in size at runtime
  • 9. An Array Can Be Homogeneous Heterogeneous
  • 10. An Array Can Be Dense Sparse
  • 11. Null versus Sparse Array with Null Sparse
  • 12. What is a Vector? A Vector is a new type of Array introduced with Flash Player 10. It’s primary benefits are performance and type safety
  • 13. A Vector Is Dense (no gaps) Is Homogenous (always the same base class) Can be fixed length
  • 14. Syntax Array Vector var a:Array = new Array(); var v:Vector.<uint> = new Vector.<uint>(n); a[0] = “value”; v[0] = “value”; //error a[1] = 345; v[1] = 345; a.push( 123 ); v.push( 123 ); trace( v.length ); trace( v.length );
  • 15. A ByteArray About the lowest level memory access there is in ActionScript Let’s you access the raw bytes and order of data. Up to you to manage what exists inside of the array
  • 16. Syntax ByteArray var byteArray:ByteArray = new ByteArray(); byteArray.writeBoolean(true); byteArray.writeDouble(Math.PI); byteArray.position = 0; trace( byteArray.readBoolean() ); //true trace( byteArray.readDouble() ); //3.1415926535897 trace( byteArray[ 2 ] ); //9… why?
  • 17. Breaking Apart Pete When working with a ByteArray, the indices do not necessarily indicate discrete objects. They indicate discrete bytes
  • 18. Position Byte Array also has a position indicator. This indicates the next place you will read from or write to. This is the beginning of a very important concept.
  • 19. Great Things about Array Array’s can be extremely fast to access data at a known index. They also provide random access, meaning you can ask for the value at position 3 without caring that there is a position 2
  • 20. Bad Things about Array Array’s can be pretty slow when you need to insert or delete information from the middle Moving from element to element (moving from 2 to 3) takes a fixed amount of time, which is good, but you also don’t get a speed advantage because those two are right next to eachother
  • 27. Array Searching Searching an Array generally involves iterating through each element looking for the value you would like. If the array is sorted, you can make the search a smarter
  • 28. Array Collections At some point you may have been told to use the ArrayCollection class. So, what is it? ..It’s a wrapper around an array. It provides the basic access to array by acting as a proxy. This allows ArrayCollection to lie to you
  • 29. Key Lies Since ArrayCollection controls all information flow in and out of its little regime, it can lie both about how big the array is and about the order of the elements. It does this by creating a duplicate array that points to the original, when and if it is convenient. Fortunately, you control this by means of the sort and filterFunction
  • 30. Sorted Array Collection One you have provided the ArrayCollection a Sort instance and called its refresh() method, it builds an array which maps the original elements to the new sort
  • 31. Syntax ArrayCollection Sort var ac:ArrayCollection = new ArrayCollection(data); var ac:ArrayCollection = new ArrayCollection(); var sort:Sort = new Sort(); var field:SortField = new SortField( quot;hireDatequot; ); sort.fields = [ field ]; ac.sort = sort; ac.refresh();
  • 32. Collection Resorted Sorting doesn’t actually need to shift the original data, just the new internal array.
  • 33. Searching a Collection Once an ArrayCollection has been sorted, searching it is a very efficient and easy process. The reduction in time to sort a large ArrayCollection is very significant over an array.
  • 34. Filtered Array Collection One you have provided the ArrayCollection with a filter function and called its refresh() method, it builds an array which maps the original elements to the new array if they pass the test in your function
  • 35. Syntax ArrayCollection Filter var ac:ArrayCollection = new ArrayCollection(); ac.filterFunction = ifIFeelLikeIt; ac.refresh(); function ifIFeelLikeIt( item:Object ):Boolean { //do some logic and decide return ( item != Andy ); }
  • 37. Another Key Feature While not busy deceiving you, ArrayCollection has a handful of really useful additional features. The reason most people use ArrayCollection, even if they aren’t sure why, is that it is an event dispatcher. When you use the ArrayCollection with DataBinding, the ArrayCollection informs you of changes
  • 39. Collection Internals trace( collection[ 3 ] ); getProperty( 3 ); getItemAt( 3 ); get localIndex[ 3 ]; setProperty( 3, 8 ); collection[ 3 ] = 8; setItemAt( 8, 3 ); list.setItemAt; Update Value Dispatch Event
  • 40. Final One Through inheritance ArrayCollection also provides one final important feature, it can work with a cursor. A bit like the position in a ByteArray, the cursor points to a given object in the collection. You can use the cursor to move forward to the next item, move back to a previous item, seek to well-known locations or search sorted data.
  • 43. DataGrid and List Base In fact, the List base controls in Flex use these cursors pretty much exclusively inside of these components. One of the reasons they can accept many different types of input is they simply wrap the input in one of (n) classes that implement ICollectionView
  • 44. ICollectionView ICollectionView mandates that an object can dispatch events, understands how to sort, filter and refresh along with a handful of other items, and, most importantly, that the object can create a cursor that will move through an child objects.
  • 45. ICollectionView This is really important as it allows us to use various types of Data Structures, other than just ArrayCollection to fill this need. For example, we can trivially make a VectorCollection which uses vectors instead of Arrays. We can create a ByteArrayCollection should we feel so inclined.
  • 46. Cursor/Iterator With this new found knowledge, we could also explore data structures that don’t exist in Flex today, but could. One data structure in particular is really fantastic when you need to do frequent inserts/deletes or simply move through the values sequentially, a linked list.
  • 47. Linked List A linked list is a data structure that is just a sequence of pieces of data, often called nodes. Linked lists can be implemented in a single fashion, where each node only knows about the next, or, in a double fashion where each node knows who came before it and who came after it
  • 48. Linked List Each node in this linked list knows about who is sequentially before it, and who is sequentially after. They don’t have any information about the other nodes
  • 49. Inserting List This makes the process of inserting into a list extremely efficient. There is no need to move any of the existing nodes, you simply change who (in this case) Pete and Andy believe are next and previous.
  • 50. Deleting List Deleting is equally as efficient. In this case when we chose to remove Andy, we simply change the previous and next of Pete and Thomas
  • 51. Andy is GCed Eventually in the future, the garbage collector ruthlessly slaughters Andy. However, that is not the concern of this session.
  • 52. Searching List Searching an unsorted list takes about the same effort as searching an Array.
  • 53. Searching By Index Where linked lists are much slower is when you need to find an item at a particular index. For an array, that is a very fast operation. Here it requires a walk through the list.
  • 54. Working with Cursors The paradigm used by cursors, however, works very well with lists where we generally are moving between nodes
  • 55. Results For good measure, let’s take a look at some data
  • 56. Q&A Seriously? You must have some questions by now?
  • 57. Resources Blog Aggregator (All of the Digital Primates) http://blogs.digitalprimates.net/ My Blog Specifically http://blogs.digitalprimates.net/codeSlinger/ Follow Me on Twitter mlabriola