FAQ Home :
How to I implement a JAVA vector class in Lotusscript. Lotus Notes Lists Data Type. Hash table design.
How to I implement a JAVA vector class in Lotusscript. Lotus Notes Lists Data Type. Hash table design.

AnswerThe vector class allows enumeration. The HASH table class uses lists to store the data.
'VECTOR Class
Option Public
Option Declare
Use "HashTable.Class"


' Created by Steve Robinson - Appsworks 09/10/2000
'www.appsworks.com
'steve.robinson@appsworks.com
Class Vector

Private p_oHashTable As HashTable
Private p_idx As Integer
Private Cursor As Integer
Private enum_pointer As Integer

Property Get hasMoreElements As Integer
If enum_pointer < p_idx Then
hasMoreElements = True
Else
hasMoreElements = False
End If
End Property

Sub new()
Dim count As Integer
Set p_oHashTable = New Hashtable
p_idx=0
enum_pointer = 0
End Sub

Public Function AddElement(obj As Variant)
cursor=p_idx
Call p_oHashTable.addElement(Cstr(p_idx),obj)
p_idx=p_idx+1
End Function

'AddElementAt(position as integer,obj as variant)
'RemoveElementAt(position as integer)
'GetElementAt(position as integer) as variant


'########### Enumeration methods ##################
Function getElement As Variant
'Set getElement=p_oHashTable.GetElement(Cstr(enum_pointer))
getElement=p_oHashTable.GetElement(Cstr(enum_pointer))
'Msgbox enum_pointer
enum_pointer = enum_pointer + 1
End Function

Public Sub resetEnumeration
Me.enum_pointer = 0
End Sub
'########### END Enumeration methods ##############
Function getFirstElement As Variant
Cursor=0
getFirstElement=p_oHashTable.GetElement(Cstr(Cursor))
End Function

Function getLastElement As Variant
Cursor=p_idx-1
getLastElement=p_oHashTable.GetElement(Cstr(Cursor))
End Function

Function getNextElement As Variant
Cursor=Cursor+1
getNextElement=p_oHashTable.GetElement(Cstr(Cursor))
End Function

Function getPreviousElement As Variant
Cursor=Cursor-1
getPreviousElement=p_oHashTable.GetElement(Cstr(Cursor))
End Function

Function getCount As Integer
getCount=p_idx
End Function

End Class




'HASH TABLEclass:
Class HashTable

Private p_List_HashTable List As Variant

Property Get getList As Variant
getList=p_List_Hashtable
End Property

Public Function hasElement(id As String) As Integer
'stack.push "(HashTable..hasElement)"
hasElement = Iselement( Me.p_List_HashTable( Lcase( id ) ) )
'stack.pop "(HashTable..hasElement)"
End Function

Public Function getElement(id As String) As Variant
'stack.push "(HashTable..getElement)"
If Not id ="" Then

If Iselement( Me.p_List_HashTable( Lcase( id ) ) ) Then
If Isobject(Me.p_List_HashTable( Lcase( id ) ) ) Then
Set getElement = Me.p_List_HashTable( Lcase( id ) )
Else
getElement = Me.p_List_HashTable( Lcase(id) )
End If
Else
Set getElement = Nothing
End If

End If
'stack.pop "(HashTable..getElement)"
End Function

Public Function addElement(id As String, obj As Variant) As Variant
'Returns the object added to the HashTable or nothing if it was not added
'stack.push "(HashTable..addElement)"
If Not id ="" Then

If Isobject( obj ) Then
Set Me.p_List_HashTable( Lcase( id ) ) = obj
Set addElement = Me.p_List_HashTable( Lcase( id ) )
Else
Me.p_List_HashTable( Lcase( id ) ) = obj
addElement = Me.p_List_HashTable( Lcase( id ) )
End If
Else
Set addElement = Nothing
End If

'stack.pop "(HashTable..addElement)"
End Function

Function removeElement(id As String) As Variant
'Returns the object removed from the HashTable or nothing if not present
'stack.push "(HashTable..removeElement)"
If Not id ="" Then

If Iselement( Me.p_List_HashTable( Lcase( id ) ) ) Then
'First we get the element so we can return it

If Isobject(Me.p_List_HashTable( Lcase( id ) ) ) Then
Set removeElement = Me.p_List_HashTable( Lcase( id ) )
Else
removeElement = Me.p_List_HashTable( Lcase(id) )
End If

'now we remove the element
Erase Me.p_List_HashTable( Lcase(id) )
Else
'no element was found
Set removeElement = Nothing
End If
End If
'stack.pop "(HashTable..removeElement)"
End Function

Public Function close() As Integer
Forall e In Me.p_List_HashTable
Set e = Nothing
End Forall
End Function

Sub delete
Call Me.close()
End Sub

End Class




'TEST
Use "vector.class"
Dim v As New Vector
Dim element As Variant
v.addElement("This is the bit of string data: A number follows")
v.addElement(1001)
v.addElement("This is the bit of string data: A number follows")
v.addElement(1002)

While v.hasMoreElements
element=v.getElement
Msgbox element
Wend


element=v.getFirstElement
Msgbox "GetFirstElement=" & element

element=v.getNextElement
Msgbox "GetNextElement=" & element

element=v.getLastElement
Msgbox "GetLastElement=" & element
Attachments -none-
Applies to versions4.x; 5.x; 6.x
FAQ Provided BySteve Robinson
Credithttp://www.appsworks.com
 Forum Latest Entries
29/07/2010 Lotus Notes Forum - AppendDocLink to Doc in Db-A to from a Doc in Db-B    (Rus)
28/07/2010 Lotus Notes Forum - Get Document from another db and appenddoc link to a field in source    (Rus)
24/06/2010 Lotus Notes Forum - Lotus Notes 6.5 Programming Certification Test    (Charles)
21/06/2010 Lotus Notes Forum - Consult    (Rogers )
09/06/2010 Lotus Notes Forum - #error : Must specify type of OS ("DOS", "OS2", etc) on C command line    (Abhi)
31/05/2010 Lotus Notes Forum - Note mail error    (Anonymous)
28/05/2010 Lotus Notes Forum - lotus notes 8 calendars & email setup...    (Dermick Vaughn)
19/05/2010 Lotus Notes Forum - Stop sending delivery and read receipts    (Simon)
19/05/2010 Lotus Notes Forum - Folder Restore Tool v2.5 is released, try for ten databases for free    (Kim van den Berg)
19/05/2010 Lotus Notes Forum - Try our Archive Solution for free for ten databases (mail/applications/quickr places)    (Kim van den Berg)
14/05/2010 Lotus Notes Forum - Adobe fillable form submit Email button not working with lotus    (Anthony )
12/05/2010 Lotus Notes Forum - Recipients on archived mails differ from regular mail    (Borja)
03/05/2010 Lotus Notes Forum - Name change only partially works    (Anonymous)
02/05/2010 Lotus Notes Forum - How to edit value in MASTER from, and backupdate MAIN form??    (Julee)
22/04/2010 Lotus Notes Forum - Note 8 Alarms Not Working    (Tony D)
07/04/2010 Lotus Notes Forum - Lotus Notes Agent to send an e-mail every month    (Lorant)
31/03/2010 Lotus Notes Forum - Lotus Notes C++, LNText Item, Unicode    (Matt)
19/03/2010 Lotus Notes Forum - Searching for a date in a document collection    (Kris Mitchell)
16/03/2010 Lotus Notes Forum - Lotus CAPI --> CSharp    (HW)
12/03/2010 Lotus Notes Forum - Notes IMAP connection    (Charl)
 Latest Tips & Tricks
10/07/2009Terminal Services Tips & Tricks - How to kill terminal server sessions. Utilities for terminal services: qwinsta and rwinsta(Steven Charles Robinson)
10/07/2009.NET Tips & Tricks - The type or namespace name could not be found (are you missing a using directive or an assembly reference?)(SCRobinson)
10/07/2009Terminate Lotus Notes Processes, Error Tips & Tricks - Lotus Notes: An Error Was Encountered While Opening A Window(Steven Charles Robinson)
26/04/2007LotusScript Mail, SMTP, Spam, Junkmail Tips & Tricks - How to drag and drop spam into junk mail filter using LotusScript(Steven Charles Robinson)
31/10/2006Terminate Lotus Notes Processes, Error Tips & Tricks - Lotus Notes: An Error Was Encountered While Opening A Window(Steven Charles Robinson)
23/10/2006Errors, SMTP, Internet Sites, Configuration, Administration, Domino 7 Tips & Tricks - Domino authentication is not enabled in the smtp internet site document(Steven Charles Robinson)
20/10/2006Articles Tips & Tricks - Have you see our recent arcticle in "The View": Proven techniques for abstracting UI from data using XML, XSL and Domino.(Steven Charles Robinson)
26/09/2006.NET Tips & Tricks - If your looking for .NET tips visit http://www.codedotnet.net(S C Robinson)
25/09/2006Using Lotus Notes Tips & Tricks - Save the Window state of a Lotus Notes client on shutdown.(Steven Charles Robinson)
22/09/2006NET, Culture, Globalization Tips & Tricks - How to find out the current culture in a .NET application.(Steve C Robinson)
© 2003 notes411.com. All rights reserved. Disclaimer. site designed & developed by appsworks.com
Lotus Notes is a registered trademark of IBM. This site is not affiliated with IBM or Lotus.
 News

 Google Box
 Sponsor
ClearCase, Subversion, WebSphere Consulting
 Best in the Industry
Lotus Notes & Domino FAQ